GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-6c790bf5c0
psdriver/draw_bitmap.c
Go to the documentation of this file.
1 #include "psdriver.h"
2 
3 void PS_Bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
4 {
5  int i, j;
6 
7  output("%d %d %d %d BITMAP\n", cur_x, cur_y, ncols, nrows);
8 
9  for (j = 0; j < nrows; j++) {
10  unsigned int bit = 0x80;
11  unsigned int acc = 0;
12 
13  for (i = 0; i < ncols; i++) {
14  unsigned int k = buf[j * ncols + i];
15 
16  if (k > (unsigned int)threshold)
17  acc |= bit;
18 
19  bit >>= 1;
20 
21  if (!bit) {
22  output("%02X", acc);
23  bit = 0x80;
24  acc = 0;
25  }
26  }
27 
28  if (bit != 0x80)
29  output("%02X", acc);
30 
31  output("\n");
32  }
33 }
double cur_x
Definition: driver/init.c:32
double cur_y
Definition: driver/init.c:33
void PS_Bitmap(int ncols, int nrows, int threshold, const unsigned char *buf)
void output(const char *fmt,...)