mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #27469 from sturkmen72:png-fixes
Fix for 2 channel PNGs #27469 closes #26825 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -508,11 +508,6 @@ bool PngDecoder::readData( Mat& img )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Asking for blend over with no alpha is invalid.
|
||||
if (bop == 1 && mat_cur.channels() != 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(&m_chunkIHDR.p[8], &chunk.p[12], 8);
|
||||
|
||||
@@ -1654,7 +1649,8 @@ bool PngEncoder::writeanimation(const Animation& animation, const std::vector<in
|
||||
else
|
||||
tmp = animation.still_image;
|
||||
|
||||
cvtColor(tmp, tmp, COLOR_BGRA2RGBA);
|
||||
if (tmp.channels() > 2)
|
||||
cvtColor(tmp, tmp, COLOR_BGRA2RGBA);
|
||||
apngFrame.setMat(tmp);
|
||||
|
||||
deflateRectOp(apngFrame.getPixels(), x0, y0, w0, h0, bpp, rowbytes, zbuf_size, 0);
|
||||
|
||||
@@ -669,14 +669,15 @@ TEST(Imgcodecs_APNG, animation_imread_preview)
|
||||
{
|
||||
// Set the path to the test image directory and filename for loading.
|
||||
const string root = cvtest::TS::ptr()->get_data_path();
|
||||
const string filename = root + "readwrite/033.png";
|
||||
const string filename = root + "readwrite/034.png";
|
||||
cv::Mat imread_result;
|
||||
cv::imread(filename, imread_result, cv::IMREAD_UNCHANGED);
|
||||
EXPECT_FALSE(imread_result.empty());
|
||||
|
||||
Animation animation;
|
||||
imreadanimation(filename, animation);
|
||||
ASSERT_TRUE(imreadanimation(filename, animation));
|
||||
EXPECT_FALSE(animation.still_image.empty());
|
||||
EXPECT_EQ((size_t)2, animation.frames.size());
|
||||
|
||||
EXPECT_EQ(0, cv::norm(animation.still_image, imread_result, cv::NORM_INF));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user