Hello!
In pixbuf-renderer.c, I've noticed code like this:
x1 = (gint)floor(x / pr->tile_width) * pr->tile_width;
x2 = (gint)ceil((x + w) / pr->tile_width) * pr->tile_width;
floor and ceil make sense only with float, x/pr->tile_width is integer
division (and only then division result implicitly casted to float).
Attached patch fixes that.
--- geeqie-20090616/src/pixbuf-renderer.c.orig 2009-06-16 00:32:50.000000000 +0400
+++ geeqie-20090616/src/pixbuf-renderer.c 2009-06-17 04:50:05.000000000 +0400
@@ -79,6 +79,10 @@
*/
#define PR_MIN_SCALE_SIZE 8
+/* round A up/down to integer count of B */
+#define ROUND_UP(A,B) ((gint)(((A)+(B)-1)/(B))*(B))
+#define ROUND_DOWN(A,B) ((gint)(((A))/(B))*(B))
+
typedef enum {
TILE_RENDER_NONE = 0, /* do nothing */
TILE_RENDER_AREA, /* render an area of the tile */
@@ -2019,11 +2023,11 @@
gint y1, y2;
GList *work;
- x1 = (gint)floor(x / pr->tile_width) * pr->tile_width;
- x2 = (gint)ceil((x + w) / pr->tile_width) * pr->tile_width;
+ x1 = ROUND_DOWN(x, pr->tile_width);
+ x2 = ROUND_UP(x + w, pr->tile_width);
- y1 = (gint)floor(y / pr->tile_height) * pr->tile_height;
- y2 = (gint)ceil((y + h) / pr->tile_height) * pr->tile_height;
+ y1 = ROUND_DOWN(y, pr->tile_height);
+ y2 = ROUND_UP(y + h, pr->tile_height);
work = pr->tiles;
while (work)
@@ -3015,11 +3019,11 @@
if (clamp && !pr_clamp_to_visible(pr, &x, &y, &w, &h)) return FALSE;
- x1 = (gint)floor(x / pr->tile_width) * pr->tile_width;
- x2 = (gint)ceil((x + w) / pr->tile_width) * pr->tile_width;
+ x1 = ROUND_DOWN(x, pr->tile_width);
+ x2 = ROUND_UP(x + w, pr->tile_width);
- y1 = (gint)floor(y / pr->tile_height) * pr->tile_height;
- y2 = (gint)ceil((y + h) / pr->tile_height) * pr->tile_height;
+ y1 = ROUND_DOWN(y, pr->tile_height);
+ y2 = ROUND_UP(y + h, pr->tile_height);
for (j = y1; j <= y2; j += pr->tile_height)
{
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geeqie-devel mailing list
Geeqie-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geeqie-devel