Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Area.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-12-18 12:03:15 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-12-18 12:14:51 (GMT)
commitf88201e7622c14bcaaea0426ddc3cb730509acf2 (patch)
tree6e1553110396b9de4f21e96b0e67bf2c84aa013d /Area.py
parent2b2f9aa27828f44ebdce0af32566f74b0762178c (diff)
Fix pick color math - SL #4333
The value obtained by read the pick color tool was wrong, because the range is 0 to 255, and we use it between 0 and 65535 A similar problem is described here [1] Aditionally, this patch set the right mouse cursor for the case where the bucket do not fill anything, because the selected color is the same to the color in the point to fill. Previously the clock cursor was not removed, and confused the user. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org> [1] http://old.nabble.com/-cairo--Getting-wrong-cairo-pixel-color.-td31256086.html
Diffstat (limited to 'Area.py')
-rw-r--r--Area.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Area.py b/Area.py
index 48f9757..9318266 100644
--- a/Area.py
+++ b/Area.py
@@ -827,6 +827,10 @@ class Area(Gtk.DrawingArea):
old_color = pixels[x + y * width]
if old_color == fill_color:
logging.debug('Already filled')
+ # reset the cursor
+ display = Gdk.Display.get_default()
+ cursor = Gdk.Cursor.new_from_name(display, 'paint-bucket')
+ self.get_window().set_cursor(cursor)
return
if FALLBACK_FILL:
@@ -884,11 +888,14 @@ class Area(Gtk.DrawingArea):
cairo_context.set_operator(cairo.OPERATOR_SOURCE)
cairo_context.fill()
cairo_surface.flush()
+
# Read the pixel
pixels = cairo_surface.get_data()
- red = ord(pixels[2]) * 256
- green = ord(pixels[1]) * 256
- blue = ord(pixels[0]) * 256
+
+ # the values are between 0 and 255
+ red = ord(pixels[2]) / 255.0 * 65535.0
+ green = ord(pixels[1]) / 255.0 * 65535.0
+ blue = ord(pixels[0]) / 255.0 * 65535.0
stroke_color = Gdk.Color(red, green, blue)