mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
LibGfx: Implement SUBTRACT_GREEN_TRANSFORM for webp lossless decoder
This commit is contained in:
parent
cdc77f7512
commit
8760376abe
1 changed files with 19 additions and 1 deletions
|
@ -636,6 +636,23 @@ public:
|
|||
|
||||
Transform::~Transform() = default;
|
||||
|
||||
// https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#43_subtract_green_transform
|
||||
class SubtractGreenTransform : public Transform {
|
||||
public:
|
||||
virtual ErrorOr<void> transform(Bitmap&) override;
|
||||
};
|
||||
|
||||
ErrorOr<void> SubtractGreenTransform::transform(Bitmap& bitmap)
|
||||
{
|
||||
for (ARGB32& pixel : bitmap) {
|
||||
Color color = Color::from_argb(pixel);
|
||||
u8 red = (color.red() + color.green()) & 0xff;
|
||||
u8 blue = (color.blue() + color.green()) & 0xff;
|
||||
pixel = Color(red, color.green(), blue, color.alpha()).value();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// https://developers.google.com/speed/webp/docs/riff_container#simple_file_format_lossless
|
||||
|
@ -702,7 +719,8 @@ static ErrorOr<void> decode_webp_chunk_VP8L(WebPLoadingContext& context, Chunk c
|
|||
case COLOR_TRANSFORM:
|
||||
return context.error("WebPImageDecoderPlugin: VP8L COLOR_TRANSFORM handling not yet implemented");
|
||||
case SUBTRACT_GREEN_TRANSFORM:
|
||||
return context.error("WebPImageDecoderPlugin: VP8L SUBTRACT_GREEN_TRANSFORM handling not yet implemented");
|
||||
TRY(transforms.try_append(TRY(try_make<SubtractGreenTransform>())));
|
||||
break;
|
||||
case COLOR_INDEXING_TRANSFORM:
|
||||
return context.error("WebPImageDecoderPlugin: VP8L COLOR_INDEXING_TRANSFORM handling not yet implemented");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue