diff options
author | Gonzalo Odiard <godiard@sugarlabs.org> | 2010-12-09 16:37:46 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@sugarlabs.org> | 2010-12-09 16:37:46 (GMT) |
commit | b62de37c04c0d49b145766b9cb097e80012e4a04 (patch) | |
tree | 371afb8313bc6cf9706b19260e126eb8e67d4e3f /Area.py | |
parent | 29d0d8390e880ea3f098648249f0f7f627da6655 (diff) |
Pylint corrections
Diffstat (limited to 'Area.py')
-rw-r--r-- | Area.py | 56 |
1 files changed, 29 insertions, 27 deletions
@@ -893,10 +893,11 @@ class Area(gtk.DrawingArea): """ - def proc_grayscale(): - self.temp_pix.saturate_and_pixelate(self.temp_pix, 0, 0) + def proc_grayscale(temp_pix): + temp_pix.saturate_and_pixelate(temp_pix, 0, 0) + return temp_pix - self._do_process(proc_grayscale) + self._do_process(widget, proc_grayscale) def invert_colors(self, widget): """Apply invert effect. @@ -906,31 +907,32 @@ class Area(gtk.DrawingArea): """ - def proc_invert_color(): + def proc_invert_color(temp_pix): try: import numpy - pix_manip2 = self.temp_pix.get_pixels_array() + pix_manip2 = temp_pix.get_pixels_array() pix_manip = numpy.ones(pix_manip2.shape, dtype=numpy.uint8) \ * 255 pix_manip2 = pix_manip - pix_manip2 - self.temp_pix = gtk.gdk.pixbuf_new_from_array(pix_manip2, + temp_pix = gtk.gdk.pixbuf_new_from_array(pix_manip2, gtk.gdk.COLORSPACE_RGB, 8) except: import string - a = self.temp_pix.get_pixels() + a = temp_pix.get_pixels() b = len(a) * ['\0'] for i in range(len(a)): b[i] = chr(255 - ord(a[i])) buff = string.join(b, '') - self.temp_pix = gtk.gdk.pixbuf_new_from_data(buff, - self.temp_pix.get_colorspace(), - self.temp_pix.get_has_alpha(), - self.temp_pix.get_bits_per_sample(), - self.temp_pix.get_width(), - self.temp_pix.get_height(), - self.temp_pix.get_rowstride()) + temp_pix = gtk.gdk.pixbuf_new_from_data(buff, + temp_pix.get_colorspace(), + temp_pix.get_has_alpha(), + temp_pix.get_bits_per_sample(), + temp_pix.get_width(), + temp_pix.get_height(), + temp_pix.get_rowstride()) + return temp_pix - self._do_process(proc_invert_color) + self._do_process(widget, proc_invert_color) def mirror(self, widget, horizontal=True): """Apply mirror horizontal/vertical effect. @@ -941,31 +943,31 @@ class Area(gtk.DrawingArea): """ - def proc_mirror(): - self.temp_pix = self.temp_pix.flip(self.horizontal) + def proc_mirror(temp_pix): + return temp_pix.flip(self.horizontal) self.horizontal = horizontal - self._do_process(proc_mirror) + self._do_process(widget, proc_mirror) - def _do_process(self, apply_process): + def _do_process(self, widget, apply_process): width, height = self.window.get_size() if self.selmove: size = self.pixmap_sel.get_size() - self.temp_pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, + temp_pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, size[0], size[1]) - self.temp_pix.get_from_drawable(self.pixmap_sel, + temp_pix.get_from_drawable(self.pixmap_sel, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, size[0], size[1]) else: - self.temp_pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, + temp_pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height) - self.temp_pix.get_from_drawable(self.pixmap, + temp_pix.get_from_drawable(self.pixmap, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, width, height) - apply_process() + temp_pix = apply_process(temp_pix) if self.selmove: - self.pixmap_sel.draw_pixbuf(self.gc, self.temp_pix, 0, 0, 0, 0, + self.pixmap_sel.draw_pixbuf(self.gc, temp_pix, 0, 0, 0, 0, size[0], size[1], dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0) @@ -979,11 +981,11 @@ class Area(gtk.DrawingArea): self.orig_x - 1, self.orig_y - 1, size[0] + 2, size[1] + 2) else: - self.pixmap.draw_pixbuf(self.gc, self.temp_pix, 0, 0, 0, 0, + self.pixmap.draw_pixbuf(self.gc, temp_pix, 0, 0, 0, 0, width, height, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0) - del self.temp_pix + del temp_pix self.queue_draw() if not self.selmove: |