diff options
author | Manuel QuiƱones <manuel.por.aca@gmail.com> | 2011-04-18 15:36:53 (GMT) |
---|---|---|
committer | Manuel QuiƱones <manuel.por.aca@gmail.com> | 2011-04-18 15:36:53 (GMT) |
commit | 8ccccdaf7ce7dae362e63ec18392becc5ca3dd7d (patch) | |
tree | 94c6781192fa298c9dc304e04352c4d0feae1376 /Desenho.py | |
parent | 8ad0277ba3ad15fdb9c877ac63de7e65941fee12 (diff) |
Stamp resize
Diffstat (limited to 'Desenho.py')
-rw-r--r-- | Desenho.py | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -204,21 +204,29 @@ class Desenho: elif shape == 'stamp': if widget.is_selected(): # Change stamp, get it from selection: - size = widget.pixmap_sel.get_size() + width, height = widget.pixmap_sel.get_size() self.pixbuf_stamp = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, - 8, size[0], size[1]) + 8, width, height) self.pixbuf_stamp.get_from_drawable(widget.pixmap_sel, - gtk.gdk.colormap_get_system(), 0, 0, 0, 0, size[0], size[1]) + gtk.gdk.colormap_get_system(), 0, 0, 0, 0, width, height) + self.stamp_size = 0 try: self.pixbuf_stamp except: pass else: - width = self.pixbuf_stamp.get_width() - height = self.pixbuf_stamp.get_height() - # TODO resize stamp to fit brush size - widget.pixmap.draw_pixbuf(gc, self.pixbuf_stamp, + if self.stamp_size != size: + # Resize stamp to fit brush size as the width: + self.stamp_size = size + w = self.pixbuf_stamp.get_width() + h = self.pixbuf_stamp.get_height() + wr, hr = size, int(size * h * 1.0 / w) + self.resized_stamp = self.pixbuf_stamp.scale_simple(wr, hr, gtk.gdk.INTERP_HYPER) + + width = self.resized_stamp.get_width() + height = self.resized_stamp.get_height() + widget.pixmap.draw_pixbuf(gc, self.resized_stamp, 0, 0, coords[0] - width / 2, coords[1] - height / 2, width, height) if last: |