mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:48:11 +00:00
Tests/LibGfx: More preparation for lossy and alpha handling
If someone comes along who wants to implement lossy webp decoding, they now only need to implement decode_webp_chunk_VP8() and everything might Just Work. It also makes it possible to implement alpha chunk decoding before implementing lossy decoding (by making decode_webp_chunk_VP8() return an empty black bitmap for testing).
This commit is contained in:
parent
23386ac73a
commit
e9f5c9ab9d
1 changed files with 14 additions and 2 deletions
|
@ -299,6 +299,14 @@ static ErrorOr<VP8Header> decode_webp_chunk_VP8_header(WebPLoadingContext& conte
|
|||
return VP8Header { version, show_frame, size_of_first_partition, width, horizontal_scale, height, vertical_scale };
|
||||
}
|
||||
|
||||
static ErrorOr<NonnullRefPtr<Bitmap>> decode_webp_chunk_VP8(WebPLoadingContext& context, Chunk const& vp8_chunk)
|
||||
{
|
||||
VERIFY(vp8_chunk.type == FourCC("VP8 "));
|
||||
|
||||
// FIXME: Implement webp lossy decoding.
|
||||
return context.error("WebPImageDecoderPlugin: decoding lossy webps not yet implemented");
|
||||
}
|
||||
|
||||
// https://developers.google.com/speed/webp/docs/riff_container#simple_file_format_lossless
|
||||
// https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#7_overall_structure_of_the_format
|
||||
static ErrorOr<VP8LHeader> decode_webp_chunk_VP8L_header(WebPLoadingContext& context, Chunk const& vp8l_chunk)
|
||||
|
@ -1584,9 +1592,13 @@ static ErrorOr<NonnullRefPtr<Bitmap>> decode_webp_image_data(WebPLoadingContext&
|
|||
}
|
||||
|
||||
VERIFY(image_data.image_data_chunk->type == FourCC("VP8 "));
|
||||
auto bitmap = TRY(decode_webp_chunk_VP8(context, image_data.image_data_chunk.value()));
|
||||
|
||||
// FIXME: Implement.
|
||||
return context.error("WebPImageDecoderPlugin: decoding lossy webps not yet implemented");
|
||||
if (image_data.alpha_chunk.has_value()) {
|
||||
// FIXME: Decode alpha chunk and store decoded alpha in `bitmap`.
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
// https://developers.google.com/speed/webp/docs/riff_container#assembling_the_canvas_from_frames
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue