GRASS Programmer's Manual  6.4.2(2012)
psdriver/Draw_bitmap.c
Go to the documentation of this file.
00001 
00002 #include "psdriver.h"
00003 
00004 void PS_draw_bitmap(int ncols, int nrows, int threshold,
00005                     const unsigned char *buf)
00006 {
00007     int i, j;
00008 
00009     output("%d %d %d %d BITMAP\n", cur_x, cur_y, ncols, nrows);
00010 
00011     for (j = 0; j < nrows; j++) {
00012         unsigned int bit = 0x80;
00013         unsigned int acc = 0;
00014 
00015         for (i = 0; i < ncols; i++) {
00016             unsigned int k = buf[j * ncols + i];
00017 
00018             if (k > threshold)
00019                 acc |= bit;
00020 
00021             bit >>= 1;
00022 
00023             if (!bit) {
00024                 output("%02X", acc);
00025                 bit = 0x80;
00026                 acc = 0;
00027             }
00028         }
00029 
00030         if (bit != 0x80)
00031             output("%02X", acc);
00032 
00033         output("\n");
00034     }
00035 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines