GRASS 8 Programmer's Manual 8.6.0dev(2026)-5f4f7ad06c
Loading...
Searching...
No Matches
cairodriver/draw_bitmap.c
Go to the documentation of this file.
1/*!
2 \file lib/cairodriver/draw_bitmap.c
3
4 \brief GRASS cairo display driver - draw bitmap
5
6 (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
7
8 This program is free software under the GNU General Public License
9 (>=v2). Read the file COPYING that comes with GRASS for details.
10
11 \author Lars Ahlzen <lars ahlzen.com> (original contributor)
12 \author Glynn Clements
13 */
14
15#include <grass/glocale.h>
16
17#include "cairodriver.h"
18
19/*!
20 \brief Draw bitmap
21
22 \param ncols,nrows number of columns and rows
23 \param threshold threshold value
24 \param buf data buffer
25 */
26void Cairo_Bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
27{
29 int stride;
30 unsigned char *data;
31 int i;
32
33 G_debug(1, "Cairo_Bitmap: %d %d %d", ncols, nrows, threshold);
34
35#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 8)
37#else
38#define MULTIPLE 4
39 stride = (ncols + (MULTIPLE - 1)) / MULTIPLE * MULTIPLE;
40#endif
41 data = malloc(stride * nrows);
43 nrows, stride);
44
46 G_fatal_error(_("Cairo_Bitmap: Failed to create source"));
47
48 for (i = 0; i < nrows; i++)
49 memcpy(&data[i * stride], &buf[i * ncols], ncols);
50
53
55 ca.modified = 1;
56}
void Cairo_Bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
Draw bitmap.
GRASS cairo display driver - header file.
struct cairo_state ca
cairo_t * cairo
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
double cur_x
Definition driver/init.c:32
double cur_y
Definition driver/init.c:33
#define _(str)
Definition glocale.h:10
void * malloc(unsigned)