15 #include <grass/glocale.h>
27 const unsigned char *
buf)
29 cairo_surface_t *surf;
34 G_debug(1,
"Cairo_draw_bitmap: %d %d %d", ncols, nrows, threshold);
36 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,5,8)
37 stride = cairo_format_stride_for_width(CAIRO_FORMAT_A8, ncols);
40 stride = (ncols + (MULTIPLE - 1)) / MULTIPLE * MULTIPLE;
42 data =
malloc(stride * nrows);
43 surf = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_A8, ncols,
46 if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS)
47 G_fatal_error(_(
"Cairo_draw_bitmap: Failed to create source"));
49 for (i = 0; i < nrows; i++)
50 memcpy(&data[i * stride], &buf[i * ncols], ncols);
52 cairo_surface_mark_dirty(surf);
55 cairo_surface_destroy(surf);
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
int G_debug(int level, const char *msg,...)
Print debugging message.
void Cairo_draw_bitmap(int, int, int, const unsigned char *)
Draw bitmap.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.