mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 02:17:34 +00:00
LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<>
This is a first step towards better error propagation from image codecs.
This commit is contained in:
parent
ae7656072a
commit
5a79c69b02
26 changed files with 101 additions and 100 deletions
|
@ -140,17 +140,18 @@ void SpiceAgent::on_message_received()
|
|||
m_clipboard_connection.async_set_clipboard_data(anon_buffer, "text/plain", {});
|
||||
return;
|
||||
} else {
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
ErrorOr<Gfx::ImageFrameDescriptor> frame_or_error = Gfx::ImageFrameDescriptor {};
|
||||
if (type == ClipboardType::PNG) {
|
||||
bitmap = Gfx::PNGImageDecoderPlugin(data_buffer.data(), data_buffer.size()).frame(0).image;
|
||||
frame_or_error = Gfx::PNGImageDecoderPlugin(data_buffer.data(), data_buffer.size()).frame(0);
|
||||
} else if (type == ClipboardType::BMP) {
|
||||
bitmap = Gfx::BMPImageDecoderPlugin(data_buffer.data(), data_buffer.size()).frame(0).image;
|
||||
frame_or_error = Gfx::BMPImageDecoderPlugin(data_buffer.data(), data_buffer.size()).frame(0);
|
||||
} else if (type == ClipboardType::JPG) {
|
||||
bitmap = Gfx::JPGImageDecoderPlugin(data_buffer.data(), data_buffer.size()).frame(0).image;
|
||||
frame_or_error = Gfx::JPGImageDecoderPlugin(data_buffer.data(), data_buffer.size()).frame(0);
|
||||
} else {
|
||||
dbgln("Unknown clipboard type: {}", (u32)type);
|
||||
return;
|
||||
}
|
||||
auto const& bitmap = frame_or_error.value().image;
|
||||
m_clipboard_connection.set_bitmap(*bitmap);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue