Imagebox: add proper svg resizing

This commit is contained in:
Rene Kievits 2023-04-28 20:55:47 +02:00 committed by Emmanuel Lepage Vallee
parent cb72c0a8b1
commit a44bd32cd5
1 changed files with 15 additions and 4 deletions

View File

@ -233,7 +233,16 @@ function imagebox:draw(ctx, cr, width, height)
cr:clip(self._private.clip_shape(cr, w*aspects.w, h*aspects.h, unpack(self._private.clip_args)))
end
cr:scale(aspects.w, aspects.h)
if self._private.handle then
self._private.handle:render_document(cr, Rsvg.Rectangle {
x = 0,
y = 0,
width = w * aspects.w,
height = h * aspects.h
})
else
cr:scale(aspects.w, aspects.h)
end
else
if self._private.halign == "center" then
translate.x = math.floor((width - w)/2)
@ -253,11 +262,13 @@ function imagebox:draw(ctx, cr, width, height)
if self._private.clip_shape then
cr:clip(self._private.clip_shape(cr, w, h, unpack(self._private.clip_args)))
end
if self._private.handle then
self._private.handle:render_document(cr, Rsvg.Rectangle {x = 0, y = 0, width = w, height = h})
end
end
if self._private.handle then
self._private.handle:render_cairo(cr)
else
if not self._private.handle then
cr:set_source_surface(self._private.image, 0, 0)
local filter = self._private.scaling_quality