瀏覽代碼

Workaround for lack of cairo_format_stride_for_width() prior to cairo 1.6


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35242 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 年之前
父節點
當前提交
123fc1754a
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      lib/cairodriver/Draw_bitmap.c

+ 5 - 0
lib/cairodriver/Draw_bitmap.c

@@ -33,7 +33,12 @@ void Cairo_Bitmap(int ncols, int nrows, int threshold,
 
     G_debug(1, "Cairo_Bitmap: %d %d %d", ncols, nrows, threshold);
 
+#if CAIRO_VERSION_MAJOR > 1 || CAIRO_VERSION_MAJOR == 1 && CAIRO_VERSION_MINOR >= 6
     stride = cairo_format_stride_for_width(CAIRO_FORMAT_A8, ncols);
+#else
+#define MULTIPLE 4
+    stride = (ncols + (MULTIPLE - 1)) / MULTIPLE * MULTIPLE;
+#endif
     data = malloc(stride * nrows);
     surf = cairo_image_surface_create_for_data(
 	data, CAIRO_FORMAT_A8, ncols, nrows, stride);