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
ea911d34
Commit
ea911d34
authored
Jul 14, 2016
by
thierry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove 2-channel png encoder/decoder support
parent
d40e46bc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
11 deletions
+10
-11
grfmt_png.cpp
modules/imgcodecs/src/grfmt_png.cpp
+5
-11
loadsave.cpp
modules/imgcodecs/src/loadsave.cpp
+5
-0
No files found.
modules/imgcodecs/src/grfmt_png.cpp
View file @
ea911d34
...
...
@@ -187,26 +187,21 @@ bool PngDecoder::readHeader()
if
(
bit_depth
<=
8
||
bit_depth
==
16
)
{
png_get_tRNS
(
png_ptr
,
info_ptr
,
&
trans
,
&
num_trans
,
&
trans_values
);
switch
(
color_type
)
{
case
PNG_COLOR_TYPE_RGB
:
case
PNG_COLOR_TYPE_PALETTE
:
png_get_tRNS
(
png_ptr
,
info_ptr
,
&
trans
,
&
num_trans
,
&
trans_values
);
if
(
num_trans
>
0
)
m_type
=
CV_8UC4
;
else
m_type
=
CV_8UC3
;
break
;
case
PNG_COLOR_TYPE_GRAY_ALPHA
:
case
PNG_COLOR_TYPE_RGB_ALPHA
:
m_type
=
CV_8UC4
;
break
;
case
PNG_COLOR_TYPE_GRAY_ALPHA
:
m_type
=
CV_8UC2
;
break
;
default
:
if
(
num_trans
>
0
)
m_type
=
CV_8UC2
;
else
m_type
=
CV_8UC1
;
}
if
(
bit_depth
==
16
)
...
...
@@ -230,7 +225,7 @@ bool PngDecoder::readData( Mat& img )
volatile
bool
result
=
false
;
AutoBuffer
<
uchar
*>
_buffer
(
m_height
);
uchar
**
buffer
=
_buffer
;
int
color
=
img
.
channels
()
>
2
;
int
color
=
img
.
channels
()
>
1
;
if
(
m_png_ptr
&&
m_info_ptr
&&
m_end_info
&&
m_width
&&
m_height
)
{
...
...
@@ -247,7 +242,7 @@ bool PngDecoder::readData( Mat& img )
else
if
(
!
isBigEndian
()
)
png_set_swap
(
png_ptr
);
if
(
img
.
channels
()
!=
4
&&
img
.
channels
()
!=
2
)
if
(
img
.
channels
()
<
4
)
{
/* observation: png_read_image() writes 400 bytes beyond
* end of data when reading a 400x118 color png
...
...
@@ -272,7 +267,7 @@ bool PngDecoder::readData( Mat& img )
png_set_gray_1_2_4_to_8
(
png_ptr
);
#endif
if
(
CV_MAT_CN
(
m_type
)
>
2
&&
color
)
if
(
(
m_color_type
&
PNG_COLOR_MASK_COLOR
)
&&
color
)
png_set_bgr
(
png_ptr
);
// convert RGB to BGR
else
if
(
color
)
png_set_gray_to_rgb
(
png_ptr
);
// Gray->RGB
...
...
@@ -413,7 +408,6 @@ bool PngEncoder::write( const Mat& img, const std::vector<int>& params )
png_set_IHDR
(
png_ptr
,
info_ptr
,
width
,
height
,
depth
==
CV_8U
?
isBilevel
?
1
:
8
:
16
,
channels
==
1
?
PNG_COLOR_TYPE_GRAY
:
channels
==
2
?
PNG_COLOR_TYPE_GRAY_ALPHA
:
channels
==
3
?
PNG_COLOR_TYPE_RGB
:
PNG_COLOR_TYPE_RGBA
,
PNG_INTERLACE_NONE
,
PNG_COMPRESSION_TYPE_DEFAULT
,
PNG_FILTER_TYPE_DEFAULT
);
...
...
modules/imgcodecs/src/loadsave.cpp
View file @
ea911d34
...
...
@@ -452,6 +452,8 @@ static bool imwrite_( const String& filename, const Mat& image,
Mat
temp
;
const
Mat
*
pimage
=
&
image
;
CV_Assert
(
image
.
channels
()
==
1
||
image
.
channels
()
==
3
||
image
.
channels
()
==
4
);
ImageEncoder
encoder
=
findEncoder
(
filename
);
if
(
!
encoder
)
CV_Error
(
CV_StsError
,
"could not find a writer for the specified extension"
);
...
...
@@ -588,6 +590,9 @@ bool imencode( const String& ext, InputArray _image,
{
Mat
image
=
_image
.
getMat
();
int
channels
=
image
.
channels
();
CV_Assert
(
channels
==
1
||
channels
==
3
||
channels
==
4
);
ImageEncoder
encoder
=
findEncoder
(
ext
);
if
(
!
encoder
)
CV_Error
(
CV_StsError
,
"could not find encoder for the specified extension"
);
...
...
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