[GRASS-CVS] glynn: grass6/lib/cairodriver Draw_bitmap.c,1.2,1.3
grass at intevation.de
grass at intevation.de
Thu Nov 22 16:41:45 EST 2007
Author: glynn
Update of /grassrepository/grass6/lib/cairodriver
In directory doto:/tmp/cvs-serv13492/lib/cairodriver
Modified Files:
Draw_bitmap.c
Log Message:
Work around bug with non-word-aligned surfaces
Index: Draw_bitmap.c
===================================================================
RCS file: /grassrepository/grass6/lib/cairodriver/Draw_bitmap.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Draw_bitmap.c 23 Oct 2007 23:23:42 -0000 1.2
+++ Draw_bitmap.c 22 Nov 2007 21:41:43 -0000 1.3
@@ -1,5 +1,30 @@
#include "cairodriver.h"
+static cairo_surface_t *fix_surface(cairo_surface_t *src)
+{
+ int width = cairo_image_surface_get_width(src);
+ int height = cairo_image_surface_get_height(src);
+ int stride = cairo_image_surface_get_stride(src);
+ cairo_format_t format = cairo_image_surface_get_format(src);
+ unsigned char *data = cairo_image_surface_get_data(src);
+ cairo_surface_t *dst = cairo_image_surface_create(format, width, height);
+ int stride2 = cairo_image_surface_get_stride(dst);
+ unsigned char *data2 = cairo_image_surface_get_data(dst);
+ int i;
+
+ for (i = 0; i < height; i++)
+ {
+ void *p = data + i * stride;
+ void *q = data2 + i * stride2;
+ int n = stride < stride2 ? stride : stride2;
+
+ memcpy(q, p, n);
+ }
+
+ cairo_surface_destroy(src);
+ return dst;
+}
+
void Cairo_draw_bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
{
cairo_surface_t *surf;
@@ -11,6 +36,8 @@
if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS)
G_fatal_error("Cairo_draw_bitmap: Failed to create source");
+
+ surf = fix_surface(surf);
cairo_mask_surface(cairo, surf, cur_x, cur_y);
More information about the grass-commit
mailing list