Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ImageProcess.py
diff options
context:
space:
mode:
Diffstat (limited to 'ImageProcess.py')
-rw-r--r--ImageProcess.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/ImageProcess.py b/ImageProcess.py
index 042e7ac..e8c2930 100644
--- a/ImageProcess.py
+++ b/ImageProcess.py
@@ -28,12 +28,10 @@ else:
import Image,ImageEnhance,ImageFont,ImageFilter,ImageOps, ImageDraw
def pixbuftoImage(pb):
- print "*** pixbuftoImage:",pb
width,height = pb.get_width(),pb.get_height()
return Image.fromstring("RGB",(width,height),pb.get_pixels() )
def imagetopixbuf(im):
- print "*** imagetopixbuf:", im
file1 = StringIO.StringIO()
im.save(file1, "ppm")
contents = file1.getvalue()
@@ -73,10 +71,21 @@ class ImageProcessor(gtk.DrawingArea):
self.window.process_updates( True )
def add_pixbuf_stack(self, pixbuf):
- self.pixbufs_stack.append(pixbuf)
- while len(self.pixbufs_stack) > 10:
- self.pixbufs_stack.remove(self.pixbufs_stack[0])
- self.temp_pixbuf_index = self.pixbufs_stack.index(pixbuf)
+ if self.pixbufs_stack:
+ if self.temp_pixbuf_index != self.pixbufs_stack.index(self.pixbufs_stack[-1]):
+ self.pixbufs_stack = self.pixbufs_stack[0:self.temp_pixbuf_index+1]
+ self.pixbufs_stack.append(pixbuf)
+ self.temp_pixbuf_index = self.pixbufs_stack.index(pixbuf)
+ else:
+ self.pixbufs_stack.append(pixbuf)
+ while len(self.pixbufs_stack) > 10:
+ self.pixbufs_stack.remove(self.pixbufs_stack[0])
+ self.temp_pixbuf_index = self.pixbufs_stack.index(pixbuf)
+ else:
+ self.pixbufs_stack.append(pixbuf)
+ while len(self.pixbufs_stack) > 10:
+ self.pixbufs_stack.remove(self.pixbufs_stack[0])
+ self.temp_pixbuf_index = self.pixbufs_stack.index(pixbuf)
def do_expose_event(self, event):
ctx = self.window.cairo_create()
@@ -115,6 +124,7 @@ class ImageProcessor(gtk.DrawingArea):
else:
rotacion = gtk.gdk.PIXBUF_ROTATE_CLOCKWISE
pixbuf = self.temp_pixbuf.copy().rotate_simple(rotacion)
+ self.tamanio = (int(pixbuf.get_width() * self.zoom), int(pixbuf.get_height() * self.zoom))
self.add_pixbuf_stack(pixbuf)
self.window.invalidate_rect(self.get_allocation(), True)
self.window.process_updates(True)
@@ -140,11 +150,15 @@ class ImageProcessor(gtk.DrawingArea):
def image_undo(self):
if self.pixbufs_stack and self.temp_pixbuf_index > 0:
self.temp_pixbuf_index -= 1
+ pixbuf = self.pixbufs_stack[self.temp_pixbuf_index]
+ self.tamanio = (int(pixbuf.get_width() * self.zoom), int(pixbuf.get_height() * self.zoom))
self.window.invalidate_rect(self.get_allocation(), True)
self.window.process_updates(True)
def image_redo(self):
if self.pixbufs_stack and self.temp_pixbuf_index < len(self.pixbufs_stack)-1:
self.temp_pixbuf_index += 1
+ pixbuf = self.pixbufs_stack[self.temp_pixbuf_index]
+ self.tamanio = (int(pixbuf.get_width() * self.zoom), int(pixbuf.get_height() * self.zoom))
self.window.invalidate_rect(self.get_allocation(), True)
self.window.process_updates(True)
@@ -166,16 +180,6 @@ class ImageProcessor(gtk.DrawingArea):
self.window.invalidate_rect(self.get_allocation(), True)
self.window.process_updates(True)
- def image_Offset(self,value):
- if not self.pixbufs_stack: return
- im = pixbuftoImage(self.temp_pixbuf.copy())
- w,h=im.size
- im = im.offset(w/2,h/2)
- pixbuf = imagetopixbuf(im)
- self.add_pixbuf_stack(pixbuf)
- self.window.invalidate_rect(self.get_allocation(), True)
- self.window.process_updates(True)
-
def image_Contour(self,value):
if not self.pixbufs_stack: return
im = pixbuftoImage(self.temp_pixbuf.copy())
@@ -230,7 +234,8 @@ class ImageProcessor(gtk.DrawingArea):
self.window.invalidate_rect(self.get_allocation(), True)
self.window.process_updates(True)
- def guardar_archivo(self):
- if not self.pixbufs_stack: return
- self.pixbufs_stack[self.temp_pixbuf_index].save("prueba", "png", {"quality":"100"})
+ def guardar_archivo(self, path):
+ if not self.pixbufs_stack or not path: return
+ path = "%s%s" % (path, ".png")
+ self.pixbufs_stack[self.temp_pixbuf_index].save(path, "png")