Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Desenho.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/Desenho.py b/Desenho.py
index 9c0db31..1c04e6f 100644
--- a/Desenho.py
+++ b/Desenho.py
@@ -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: