GRASS 8 Programmer's Manual 8.6.0dev(2026)-1878fdfec5
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 SPDX-FileCopyrightText: 2007-2008 Lars Ahlzen
7 SPDX-FileCopyrightText: GRASS Development Team
8 SPDX-License-Identifier: GPL-2.0-or-later
9
10 \author Lars Ahlzen <lars ahlzen.com> (original contributor)
11 \author Glynn Clements
12 */
13
14#include <grass/glocale.h>
15
16#include "cairodriver.h"
17
18/*!
19 \brief Draw bitmap
20
21 \param ncols,nrows number of columns and rows
22 \param threshold threshold value
23 \param buf data buffer
24 */
25void Cairo_Bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
26{
28 int stride;
29 unsigned char *data;
30 int i;
31
32 G_debug(1, "Cairo_Bitmap: %d %d %d", ncols, nrows, threshold);
33
34#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 8)
36#else
37#define MULTIPLE 4
38 stride = (ncols + (MULTIPLE - 1)) / MULTIPLE * MULTIPLE;
39#endif
40 data = malloc((size_t)stride * nrows);
42 nrows, stride);
43
45 G_fatal_error(_("Cairo_Bitmap: Failed to create source"));
46
47 for (i = 0; i < nrows; i++)
48 memcpy(&data[i * stride], &buf[i * ncols], ncols);
49
52
54 ca.modified = 1;
55}
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:30
double cur_y
Definition driver/init.c:31
#define _(str)
Definition glocale.h:10
void * malloc(unsigned)