Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-07-24 18:21:43 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-07-24 18:21:43 (GMT)
commit04dbf8ae9727ead8ef4e645f8d807d477db522c0 (patch)
treeddb0a41c39b7b67e3cc821099f8c33bc64db4ec1
parent5798ecd088f969fe36b57387cecc236f0198844b (diff)
Implement stamp tool with cairo
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--Area.py11
-rw-r--r--Desenho.py12
-rw-r--r--widgets.py7
3 files changed, 20 insertions, 10 deletions
diff --git a/Area.py b/Area.py
index 9c2acbb..7eabb33 100644
--- a/Area.py
+++ b/Area.py
@@ -732,11 +732,12 @@ class Area(gtk.DrawingArea):
"""
if self.is_selected():
# Change stamp, get it from selection:
- _x, _y, width, height = self.get_selection_bounds()
- self.pixbuf_stamp = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
- 8, width, height)
- self.pixbuf_stamp.get_from_drawable(self.pixmap_sel,
- gtk.gdk.colormap_get_system(), 0, 0, 0, 0, width, height)
+ pixbuf_data = StringIO.StringIO()
+ self.get_selection().write_to_png(pixbuf_data)
+ pxb_loader = gtk.gdk.PixbufLoader(image_type='png')
+ pxb_loader.write(pixbuf_data.getvalue())
+
+ self.pixbuf_stamp = pxb_loader.get_pixbuf()
self.stamp_size = 0
# Set white color as transparent:
stamp_alpha = self.pixbuf_stamp.add_alpha(True, 255, 255, 255)
diff --git a/Desenho.py b/Desenho.py
index 939a0a9..7917a55 100644
--- a/Desenho.py
+++ b/Desenho.py
@@ -164,15 +164,21 @@ class Desenho:
@param stamp_size -- integer (default 20)
"""
+
widget.desenha = False
- gc = widget.gc_brush
width = widget.resized_stamp.get_width()
height = widget.resized_stamp.get_height()
dx = coords[0] - width / 2
dy = coords[1] - height / 2
- widget.pixmap.draw_pixbuf(gc, widget.resized_stamp,
- 0, 0, dx, dy, width, height)
+
+ widget.drawing_ctx.save()
+ widget.drawing_ctx.translate(dx, dy)
+ widget.drawing_ctx.rectangle(dx, dy, width, height)
+ temp_ctx = gtk.gdk.CairoContext(widget.drawing_ctx)
+ temp_ctx.set_source_pixbuf(widget.resized_stamp, 0, 0)
+ widget.drawing_ctx.paint()
+ widget.drawing_ctx.restore()
widget.queue_draw()
diff --git a/widgets.py b/widgets.py
index 34d8a83..69890a1 100644
--- a/widgets.py
+++ b/widgets.py
@@ -123,8 +123,11 @@ class BrushButton(_ColorButton):
height = self._resized_stamp.get_height()
dx = center - width / 2
dy = center - height / 2
- self.pixmap.draw_pixbuf(self._gc, self._resized_stamp,
- 0, 0, dx, dy, width, height)
+
+ self._ctx.rectangle(dx, dy, width, height)
+ temp_ctx = gtk.gdk.CairoContext(self._ctx)
+ temp_ctx.set_source_pixbuf(self._resized_stamp, 0, 0)
+ self._ctx.paint()
else:
red = float(self._color.red) / 65535.0