LibPDF: Simplify load_image() a tiny bit

Images can't use Pattern color spaces, so we'll always have a Color.

No behavior (or perf) change.
This commit is contained in:
Nico Weber 2024-01-08 22:26:40 -05:00 committed by Andreas Kling
parent 00510e40d9
commit f7fc2df8ac
Notes: sideshowbarker 2024-07-16 19:57:55 +09:00

View file

@ -1139,16 +1139,8 @@ PDFErrorOr<Renderer::LoadedImage> Renderer::load_image(NonnullRefPtr<StreamObjec
sample = sample.slice(bytes_per_component);
component_values[i] = Value { component_value_decoders[i].interpolate(component[0]) };
}
auto color = TRY(color_space->style(component_values));
if (color.has<Color>()) {
auto c = color.get<Color>();
bitmap->set_pixel(x, y, c);
} else {
auto paint_style = color.get<NonnullRefPtr<Gfx::PaintStyle>>();
paint_style->paint(bitmap->rect(), [&](auto sample) {
bitmap->set_pixel(x, y, sample(Gfx::IntPoint(x, y)));
});
}
auto color = TRY(color_space->style(component_values)).get<Color>();
bitmap->set_pixel(x, y, color);
++x;
if (x == width) {
x = 0;