Skip to content

Commit

Permalink
Fixed bug where pixel/color information at x=0 coordinates werent shown:
Browse files Browse the repository at this point in the history
- pixel-coordinates now calculated with floor
- guard for update in layout does not apply for 0 coordinates anymore

Patch by Ruben Stein.
  • Loading branch information
Laurent Monin committed Mar 30, 2009
1 parent 9ec7080 commit be6f518
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/layout_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ void layout_status_update_pixel_cb(PixbufRenderer *pr, gpointer data)

pixbuf_renderer_get_mouse_position(pr, &x_pixel, &y_pixel);

if(x_pixel > 0 && y_pixel > 0)
if(x_pixel >= 0 && y_pixel >= 0)
{
gint r_mouse, g_mouse, b_mouse;
gint width, height;
Expand Down
4 changes: 2 additions & 2 deletions src/pixbuf-renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -4197,8 +4197,8 @@ gboolean pixbuf_renderer_get_mouse_position(PixbufRenderer *pr, gint *x_pixel_re
return FALSE;
}

x_pixel = (gint)((gdouble)(pr->x_mouse - pr->x_offset + pr->x_scroll) / pr->scale);
y_pixel = (gint)((gdouble)(pr->y_mouse - pr->y_offset + pr->y_scroll) / pr->scale);
x_pixel = floor((gdouble)(pr->x_mouse - pr->x_offset + pr->x_scroll) / pr->scale);
y_pixel = floor((gdouble)(pr->y_mouse - pr->y_offset + pr->y_scroll) / pr->scale);
x_pixel_clamped = CLAMP(x_pixel, 0, pr->image_width - 1);
y_pixel_clamped = CLAMP(y_pixel, 0, pr->image_height - 1);

Expand Down

0 comments on commit be6f518

Please sign in to comment.