Changeset 654 for gtkimageview
- Timestamp:
- 04/02/09 18:57:02 (4 years ago)
- Files:
-
- gtkimageview/src/gtkimageview.c (modified) (7 diffs)
- gtkimageview/src/gtkimageview.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gtkimageview/src/gtkimageview.c
r627 r654 351 351 352 352 static void 353 gtk_image_view_clamp_offset (GtkImageView *view, gdouble *x, gdouble*y)353 gtk_image_view_clamp_offset (GtkImageView *view, int *x, int *y) 354 354 { 355 355 Size alloc = gtk_image_view_get_allocated_size (view); … … 430 430 Size alloc = gtk_image_view_get_allocated_size (view); 431 431 432 gdouble offset_x, offset_y; 433 offset_x = (view->offset_x + center_x) * zoom_ratio - alloc.width / 2.0; 434 offset_y = (view->offset_y + center_y) * zoom_ratio - alloc.height / 2.0; 432 int offset_x, offset_y; 433 434 offset_x = (int) round ((gdouble) ((gdouble)view->offset_x + center_x) * zoom_ratio - 435 (gdouble) alloc.width / 2.0); 436 offset_y = (int) round ((gdouble) ((gdouble)view->offset_y + center_y) * zoom_ratio - 437 (gdouble) alloc.height / 2.0); 435 438 view->zoom = zoom; 436 439 437 440 gtk_image_view_clamp_offset (view, &offset_x, &offset_y); 441 438 442 view->offset_x = offset_x; 439 443 view->offset_y = offset_y; 444 440 445 gtk_image_view_update_cursor (view); 441 446 … … 561 566 interp = GDK_INTERP_NEAREST; 562 567 563 // Fix for #31. Value must be rounded or double -> int 564 // conversion can introduce error. 565 int src_x = (int)((view->offset_x + 566 (gdouble) paint_area.x - 567 (gdouble) image_area.x) + 0.5); 568 int src_y = (int)((view->offset_y + 569 (gdouble) paint_area.y - 570 (gdouble) image_area.y) + 0.5); 568 int src_x = view->offset_x + paint_area.x - image_area.x; 569 int src_y = view->offset_y + paint_area.y - image_area.y; 571 570 572 571 GdkPixbufDrawOpts opts = { … … 695 694 static void 696 695 gtk_image_view_scroll_to (GtkImageView *view, 697 gdoubleoffset_x,698 gdoubleoffset_y,696 int offset_x, 697 int offset_y, 699 698 gboolean set_adjustments, 700 699 gboolean invalidate) … … 702 701 gtk_image_view_clamp_offset (view, &offset_x, &offset_y); 703 702 704 /* Round avoids floating point to integer conversion errors. See 705 #31. */ 706 int delta_x = round (offset_x - view->offset_x); 707 int delta_y = round (offset_y - view->offset_y); 703 int delta_x = offset_x - view->offset_x; 704 int delta_y = offset_y - view->offset_y; 708 705 709 706 /* Exit early if the scroll was smaller than one (zoom space) … … 884 881 GtkImageView *view) 885 882 { 886 gdoubleoffset_x = GTK_ADJUSTMENT (adj)->value;883 int offset_x = GTK_ADJUSTMENT (adj)->value; 887 884 gtk_image_view_scroll_to (view, offset_x, view->offset_y, FALSE, FALSE); 888 885 return FALSE; … … 968 965 view->pixbuf = NULL; 969 966 view->zoom = 1.0; 970 view->offset_x = 0 .0;971 view->offset_y = 0 .0;967 view->offset_x = 0; 968 view->offset_y = 0; 972 969 view->is_rendering = FALSE; 973 970 view->show_frame = TRUE; gtkimageview/src/gtkimageview.h
r590 r654 83 83 /* Offset in zoom space coordinates of the image area in the 84 84 widget. */ 85 gdoubleoffset_x;86 doubleoffset_y;85 int offset_x; 86 int offset_y; 87 87 gboolean show_frame; 88 88 gboolean show_cursor;
