Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
7927ebf2
Commit
7927ebf2
authored
Feb 09, 2013
by
kobigurk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alpha channels support for 8-bit tiffs
parent
c527340c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
grfmt_tiff.cpp
modules/highgui/src/grfmt_tiff.cpp
+20
-2
grfmt_tiff.hpp
modules/highgui/src/grfmt_tiff.hpp
+1
-0
No files found.
modules/highgui/src/grfmt_tiff.cpp
View file @
7927ebf2
...
...
@@ -101,6 +101,11 @@ bool TiffDecoder::checkSignature( const string& signature ) const
memcmp
(
signature
.
c_str
(),
fmtSignTiffMM
,
4
)
==
0
);
}
int
TiffDecoder
::
normalizeChannelsNumber
(
int
channels
)
const
{
return
channels
>
4
?
4
:
channels
;
}
ImageDecoder
TiffDecoder
::
newDecoder
()
const
{
return
new
TiffDecoder
;
...
...
@@ -133,10 +138,11 @@ bool TiffDecoder::readHeader()
(
ncn
!=
1
&&
ncn
!=
3
&&
ncn
!=
4
)))
bpp
=
8
;
int
wanted_channels
=
normalizeChannelsNumber
(
ncn
);
switch
(
bpp
)
{
case
8
:
m_type
=
CV_MAKETYPE
(
CV_8U
,
photometric
>
1
?
3
:
1
);
m_type
=
CV_MAKETYPE
(
CV_8U
,
photometric
>
1
?
wanted_channels
:
1
);
break
;
case
16
:
m_type
=
CV_MAKETYPE
(
CV_16U
,
photometric
>
1
?
3
:
1
);
...
...
@@ -185,6 +191,7 @@ bool TiffDecoder::readData( Mat& img )
TIFFGetField
(
tif
,
TIFFTAG_SAMPLESPERPIXEL
,
&
ncn
);
const
int
bitsPerByte
=
8
;
int
dst_bpp
=
(
int
)(
img
.
elemSize1
()
*
bitsPerByte
);
int
wanted_channels
=
normalizeChannelsNumber
(
img
.
channels
());
if
(
dst_bpp
==
8
)
{
...
...
@@ -248,9 +255,20 @@ bool TiffDecoder::readData( Mat& img )
for
(
i
=
0
;
i
<
tile_height
;
i
++
)
if
(
color
)
icvCvt_BGRA2BGR_8u_C4C3R
(
buffer
+
i
*
tile_width
*
4
,
0
,
{
if
(
wanted_channels
==
4
)
{
icvCvt_BGRA2RGBA_8u_C4R
(
buffer
+
i
*
tile_width
*
4
,
0
,
data
+
x
*
4
+
img
.
step
*
(
tile_height
-
i
-
1
),
0
,
cvSize
(
tile_width
,
1
)
);
}
else
{
icvCvt_BGRA2BGR_8u_C4C3R
(
buffer
+
i
*
tile_width
*
4
,
0
,
data
+
x
*
3
+
img
.
step
*
(
tile_height
-
i
-
1
),
0
,
cvSize
(
tile_width
,
1
),
2
);
}
}
else
icvCvt_BGRA2Gray_8u_C4C1R
(
buffer
+
i
*
tile_width
*
4
,
0
,
data
+
x
+
img
.
step
*
(
tile_height
-
i
-
1
),
0
,
...
...
modules/highgui/src/grfmt_tiff.hpp
View file @
7927ebf2
...
...
@@ -103,6 +103,7 @@ public:
size_t
signatureLength
()
const
;
bool
checkSignature
(
const
string
&
signature
)
const
;
int
normalizeChannelsNumber
(
int
channels
)
const
;
ImageDecoder
newDecoder
()
const
;
protected
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment