|
@@ -48,12 +48,13 @@ Optional<DecodedImage> Client::decode_image(ReadonlyBytes encoded_data, Optional
|
|
|
DecodedImage image;
|
|
|
image.is_animated = response.is_animated();
|
|
|
image.loop_count = response.loop_count();
|
|
|
- image.frames.resize(response.bitmaps().size());
|
|
|
+ image.frames.ensure_capacity(response.bitmaps().size());
|
|
|
auto bitmaps = response.take_bitmaps();
|
|
|
- for (size_t i = 0; i < image.frames.size(); ++i) {
|
|
|
- auto& frame = image.frames[i];
|
|
|
- frame.bitmap = bitmaps[i].bitmap();
|
|
|
- frame.duration = response.durations()[i];
|
|
|
+ for (size_t i = 0; i < bitmaps.size(); ++i) {
|
|
|
+ if (!bitmaps[i].is_valid())
|
|
|
+ return {};
|
|
|
+
|
|
|
+ image.frames.empend(*bitmaps[i].bitmap(), response.durations()[i]);
|
|
|
}
|
|
|
return image;
|
|
|
}
|