diff --git a/modules/imgcodecs/src/grfmt_png.cpp b/modules/imgcodecs/src/grfmt_png.cpp index 20653cf3c1..a47db5aa2a 100644 --- a/modules/imgcodecs/src/grfmt_png.cpp +++ b/modules/imgcodecs/src/grfmt_png.cpp @@ -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 2) + cvtColor(tmp, tmp, COLOR_BGRA2RGBA); apngFrame.setMat(tmp); deflateRectOp(apngFrame.getPixels(), x0, y0, w0, h0, bpp, rowbytes, zbuf_size, 0); diff --git a/modules/imgcodecs/test/test_animation.cpp b/modules/imgcodecs/test/test_animation.cpp index 5fead70135..2d45132ffd 100644 --- a/modules/imgcodecs/test/test_animation.cpp +++ b/modules/imgcodecs/test/test_animation.cpp @@ -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)); }