| 183 | } |
| 184 | |
| 185 | static void validateGif(const fl::vector<fl::u8>& data) { |
| 186 | fl::string error; |
| 187 | fl::GifInfo info = fl::Gif::parseGifInfo(data, &error); |
| 188 | FL_CHECK_MESSAGE(info.isValid, "GIF metadata parse failed: " << error); |
| 189 | if (info.isValid) { |
| 190 | FL_CHECK_GT(info.width, 0); |
| 191 | FL_CHECK_GT(info.height, 0); |
| 192 | FL_MESSAGE("GIF: " << info.width << "x" << info.height |
| 193 | << " frames=" << info.frameCount); |
| 194 | } |
| 195 | |
| 196 | if (fl::Gif::isSupported()) { |
| 197 | fl::GifConfig config; |
| 198 | config.mode = fl::GifConfig::SingleFrame; |
| 199 | config.format = fl::PixelFormat::RGB888; |
| 200 | fl::string dec_error; |
| 201 | auto decoder = fl::Gif::createDecoder(config, &dec_error); |
| 202 | FL_REQUIRE_MESSAGE(decoder, "GIF decoder creation failed: " << dec_error); |
| 203 | auto stream = fl::make_shared<fl::memorybuf>(data.size()); |
| 204 | stream->write(data); |
| 205 | FL_REQUIRE(decoder->begin(stream)); |
| 206 | auto result = decoder->decode(); |
| 207 | if (result == fl::DecodeResult::Success) { |
| 208 | fl::Frame frame = decoder->getCurrentFrame(); |
| 209 | FL_CHECK(frame.isValid()); |
| 210 | FL_CHECK_GT(frame.getWidth(), 0); |
| 211 | FL_CHECK_GT(frame.getHeight(), 0); |
| 212 | FL_MESSAGE("GIF first frame: " << frame.getWidth() << "x" << frame.getHeight()); |
| 213 | } |
| 214 | decoder->end(); |
| 215 | } else { |
| 216 | FL_MESSAGE("GIF decoder not supported on this platform"); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | static void validateJpeg(const fl::vector<fl::u8>& data) { |
| 221 | if (fl::Jpeg::isSupported()) { |
no test coverage detected