gui: render the drawings as oblongs in the right ratio
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
ee68ec4bcc
commit
0840f353d5
|
@ -48,16 +48,27 @@ class Drawing(Gtk.EventBox):
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
self.svg = JsonSvg(self.json_data, self.orientation)
|
self.svg = JsonSvg(self.json_data, self.orientation)
|
||||||
|
width, height = -1, -1
|
||||||
|
if 'portrait' in self.orientation:
|
||||||
|
height = 1000
|
||||||
|
else:
|
||||||
|
width = 1000
|
||||||
self.pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename=self.svg.filename,
|
self.pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename=self.svg.filename,
|
||||||
width=1000,
|
width=width,
|
||||||
height=1000,
|
height=height,
|
||||||
preserve_aspect_ratio=True)
|
preserve_aspect_ratio=True)
|
||||||
self.redraw()
|
self.redraw()
|
||||||
|
|
||||||
def redraw(self):
|
def redraw(self):
|
||||||
pb = self.pixbuf.scale_simple(250 + (self.zoom * 50),
|
ratio = self.pixbuf.get_height() / self.pixbuf.get_width()
|
||||||
250 + (self.zoom * 50),
|
base = 250 + self.zoom * 50
|
||||||
GdkPixbuf.InterpType.BILINEAR)
|
if 'portrait' in self.orientation:
|
||||||
|
width = base / ratio
|
||||||
|
height = base
|
||||||
|
else:
|
||||||
|
width = base
|
||||||
|
height = base * ratio
|
||||||
|
pb = self.pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.BILINEAR)
|
||||||
self.image_svg.set_from_pixbuf(pb)
|
self.image_svg.set_from_pixbuf(pb)
|
||||||
|
|
||||||
@GObject.Property
|
@GObject.Property
|
||||||
|
|
Loading…
Reference in New Issue