mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
LibPDF: Clip images too
Since we can't clip against a general path yet, this clips images against the bounding box of the current clip path as well. Clips for images are often rectangular, so this works out well. (We wastefully still decode and color-convert the entire image. In a follow-up, we could consider only converting the unclipped part.)
This commit is contained in:
parent
5615a2691a
commit
2d8a22f4b4
1 changed files with 15 additions and 0 deletions
|
@ -1225,6 +1225,21 @@ PDFErrorOr<void> Renderer::show_image(NonnullRefPtr<StreamObject> image)
|
|||
auto width = TRY(m_document->resolve_to<int>(image_dict->get_value(CommonNames::Width)));
|
||||
auto height = TRY(m_document->resolve_to<int>(image_dict->get_value(CommonNames::Height)));
|
||||
|
||||
class ClipRAII {
|
||||
public:
|
||||
ClipRAII(Renderer& renderer)
|
||||
: m_renderer(renderer)
|
||||
{
|
||||
m_renderer.activate_clip();
|
||||
}
|
||||
~ClipRAII() { m_renderer.deactivate_clip(); }
|
||||
|
||||
private:
|
||||
Renderer& m_renderer;
|
||||
};
|
||||
|
||||
ClipRAII clip_raii(*this);
|
||||
|
||||
if (!m_rendering_preferences.show_images) {
|
||||
show_empty_image(width, height);
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue