[GRASS-CVS] glynn: grass6/lib/cairodriver Raster.c,1.2,1.3
grass at intevation.de
grass at intevation.de
Thu Nov 22 16:41:22 EST 2007
Author: glynn
Update of /grassrepository/grass6/lib/cairodriver
In directory doto:/tmp/cvs-serv13472/lib/cairodriver
Modified Files:
Raster.c
Log Message:
Fix raster position
Index: Raster.c
===================================================================
RCS file: /grassrepository/grass6/lib/cairodriver/Raster.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Raster.c 23 Oct 2007 23:23:42 -0000 1.2
+++ Raster.c 22 Nov 2007 21:41:20 -0000 1.3
@@ -18,19 +18,21 @@
/* TODO: are top and left swapped? */
- src_r = s[0][1];
- src_b = s[1][1];
src_l = s[0][0];
+ src_r = s[0][1];
src_t = s[1][0];
- dst_r = d[0][1];
- dst_b = d[1][1];
+ src_b = s[1][1];
+
+ src_w = src_r - src_l;
+ src_h = src_b - src_t;
+
dst_l = d[0][0];
+ dst_r = d[0][1];
dst_t = d[1][0];
+ dst_b = d[1][1];
- src_h = src_b - src_t + 1;
- src_w = src_r - src_l + 1;
- dst_h = dst_b - dst_t + 1;
- dst_w = dst_r - dst_l + 1;
+ dst_w = dst_r - dst_l;
+ dst_h = dst_b - dst_t;
G_debug(1, " src (TBLR): %d %d %d %d, dst (TBLR) %d %d %d %d",
src_t, src_b, src_l, src_r, dst_t, dst_b, dst_l, dst_r);
@@ -48,7 +50,7 @@
int n, int row,
const unsigned char *red, const unsigned char *grn, const unsigned char *blu, const unsigned char *nul)
{
- unsigned int *dst = (unsigned int *) src_data + row * (src_stride >> 2);
+ unsigned int *dst = (unsigned int *) (src_data + (row - src_t) * src_stride);
int i;
G_debug(3, "Cairo_scaled_raster: %d %d", n, row);
@@ -74,8 +76,9 @@
/* paint source surface onto dstination (scaled) */
cairo_save(cairo);
+ cairo_translate(cairo, dst_l, dst_t);
cairo_scale(cairo, (double) dst_w / (double) src_w, (double) dst_h / (double) src_h);
- cairo_set_source_surface(cairo, src_surf, dst_l, dst_t);
+ cairo_set_source_surface(cairo, src_surf, 0, 0);
cairo_paint(cairo);
cairo_restore(cairo);
More information about the grass-commit
mailing list