1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #27127 from sturkmen72:apng_has_hidden_frame

Changes about when APNG has a hidden frame #27127

closes : #27074

### 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:
Suleyman TURKMEN
2025-06-21 10:22:10 +03:00
committed by GitHub
parent 3259863924
commit 850b686f8a
5 changed files with 180 additions and 106 deletions
+46 -1
View File
@@ -636,6 +636,51 @@ TEST(Imgcodecs_APNG, imencode_animation)
}
}
TEST(Imgcodecs_APNG, animation_has_hidden_frame)
{
// 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";
Animation animation1, animation2, animation3;
imreadanimation(filename, animation1);
EXPECT_FALSE(animation1.still_image.empty());
EXPECT_EQ((size_t)2, animation1.frames.size());
std::vector<unsigned char> buf;
EXPECT_TRUE(imencodeanimation(".png", animation1, buf));
EXPECT_TRUE(imdecodeanimation(buf, animation2));
EXPECT_FALSE(animation2.still_image.empty());
EXPECT_EQ(animation1.frames.size(), animation2.frames.size());
animation1.frames.erase(animation1.frames.begin());
animation1.durations.erase(animation1.durations.begin());
EXPECT_TRUE(imencodeanimation(".png", animation1, buf));
EXPECT_TRUE(imdecodeanimation(buf, animation3));
EXPECT_FALSE(animation1.still_image.empty());
EXPECT_TRUE(animation3.still_image.empty());
EXPECT_EQ((size_t)1, animation3.frames.size());
}
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";
cv::Mat imread_result;
cv::imread(filename, imread_result, cv::IMREAD_UNCHANGED);
EXPECT_FALSE(imread_result.empty());
Animation animation;
imreadanimation(filename, animation);
EXPECT_FALSE(animation.still_image.empty());
EXPECT_EQ(0, cv::norm(animation.still_image, imread_result, cv::NORM_INF));
}
#endif // HAVE_PNG
#if defined(HAVE_PNG) || defined(HAVE_SPNG)
@@ -676,7 +721,7 @@ TEST(Imgcodecs_APNG, imread_animation_16u)
img = imread(filename, IMREAD_ANYDEPTH);
ASSERT_FALSE(img.empty());
EXPECT_TRUE(img.type() == CV_16UC1);
EXPECT_EQ(19519, img.at<ushort>(0, 0));
EXPECT_EQ(19517, img.at<ushort>(0, 0));
img = imread(filename, IMREAD_COLOR | IMREAD_ANYDEPTH);
ASSERT_FALSE(img.empty());