home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource5
/
334_01
/
bitmap.c
< prev
next >
Wrap
Text File
|
1991-02-06
|
52KB
|
1,052 lines
/* GNUPLOT - bitmap.c */
/*
* Copyright (C) 1990
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
* distribute the modified code. Modifications are to be distributed
* as patches to released version.
*
* This software is provided "as is" without express or implied warranty.
*
*
* AUTHORS
* Jyrki Yli-Nokari <jty@intrin.UUCP>
* Ronald J. Hartranft <rjh2@ns.cc.lehigh.edu>
* Russell Lang <rjl@monu1.cc.monash.edu.au>
*
* send your comments or suggestions to (pixar!info-gnuplot@sun.com).
*
*/
/*
** General raster plotting routines.
** Raster routines written and copyrighted 1987 by
** Jyrki Yli-Nokari (jty@intrin.UUCP)
** Intrinsic, Ltd.
**
** You may use this code for anything you like as long as
** you are not selling it and the credit is given and
** this message retained.
**
*/
/* Bitmap plotting routines derived from above raster plotting routines
* Russell Lang, 1990
*/
#include <stdio.h>
#include "plot.h"
#include "bitmap.h"
bitmap *b_p = (bitmap *)NULL; /* global pointer to bitmap */
unsigned int b_currx, b_curry; /* the current coordinates */
unsigned int b_xsize, b_ysize; /* the size of the bitmap */
unsigned int b_planes; /* number of color planes */
unsigned int b_psize; /* size of each plane */
unsigned int b_rastermode; /* raster mode rotates -90deg */
unsigned int b_linemask = 0xffff; /* 16 bit mask for dotted lines */
unsigned int b_value = 1; /* colour of lines */
unsigned int b_hchar; /* width of characters */
unsigned int b_hbits; /* actual bits in char horizontally */
unsigned int b_vchar; /* height of characters */
unsigned int b_vbits; /* actual bits in char vertically */
unsigned int b_angle; /* rotation of text */
char_box b_font[FNT_CHARS]; /* the current font */
unsigned int b_pattern[] = {0xffff, 0x1111,
0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f};
int b_maskcount = 0;
unsigned int b_lastx, b_lasty; /* last pixel set - used by b_line */
#define IN(i,size) ((unsigned)i < (unsigned)size)
/* 5x9 font, bottom row first, left pixel in lsb */
char_row fnt5x9[FNT_CHARS][FNT5X9_VBITS] = {
/* */ {000000,000000,000000,000000,000000,000000,000000,000000,000000},
/*!*/ {000000,000000,0x0004,000000,0x0004,0x0004,0x0004,0x0004,0x0004},
/*"*/ {000000,000000,000000,000000,000000,000000,0x000a,0x000a,0x000a},
/*#*/ {000000,000000,0x000a,0x000a,0x001f,0x000a,0x001f,0x000a,0x000a},
/*$*/ {000000,000000,0x0004,0x000f,0x0014,0x000e,0x0005,0x001e,0x0004},
/*%*/ {000000,000000,0x0018,0x0019,0x0002,0x0004,0x0008,0x0013,0x0003},
/*&*/ {000000,000000,0x0016,0x0009,0x0015,0x0002,0x0005,0x0005,0x0002},
/*'*/ {000000,000000,000000,000000,000000,0x0002,0x0004,0x0006,0x0006},
/*(*/ {000000,000000,0x0008,0x0004,0x0002,0x0002,0x0002,0x0004,0x0008},
/*)*/ {000000,000000,0x0002,0x0004,0x0008,0x0008,0x0008,0x0004,0x0002},
/***/ {000000,000000,0x0004,0x0015,0x000e,0x001f,0x000e,0x0015,0x0004},
/*+*/ {000000,000000,000000,0x0004,0x0004,0x001f,0x0004,0x0004,000000},
/*,*/ {000000,0x0002,0x0004,0x0006,0x0006,000000,000000,000000,000000},
/*-*/ {000000,000000,000000,000000,000000,0x001f,000000,000000,000000},
/*.*/ {000000,000000,0x0006,0x0006,000000,000000,000000,000000,000000},
/*-/-*/{000000,000000,000000,0x0001,0x0002,0x0004,0x0008,0x0010,000000},
/*0*/ {000000,000000,0x000e,0x0011,0x0013,0x0015,0x0019,0x0011,0x000e},
/*1*/ {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0006,0x0004},
/*2*/ {000000,000000,0x001f,0x0001,0x0001,0x000e,0x0010,0x0011,0x000e},
/*3*/ {000000,000000,0x000e,0x0011,0x0010,0x000c,0x0010,0x0011,0x000e},
/*4*/ {000000,000000,0x0008,0x0008,0x001f,0x0009,0x000a,0x000c,0x0008},
/*5*/ {000000,000000,0x000e,0x0011,0x0010,0x0010,0x000f,0x0001,0x001f},
/*6*/ {000000,000000,0x000e,0x0011,0x0011,0x000f,0x0001,0x0002,0x000c},
/*7*/ {000000,000000,0x0001,0x0001,0x0002,0x0004,0x0008,0x0010,0x001f},
/*8*/ {000000,000000,0x000e,0x0011,0x0011,0x000e,0x0011,0x0011,0x000e},
/*9*/ {000000,000000,0x0006,0x0008,0x0010,0x001e,0x0011,0x0011,0x000e},
/*:*/ {000000,000000,000000,0x0006,0x0006,000000,0x0006,0x0006,000000},
/*;*/ {000000,0x0001,0x0002,0x0006,0x0006,000000,0x0006,0x0006,000000},
/*<*/ {000000,000000,0x0008,0x0004,0x0002,0x0001,0x0002,0x0004,0x0008},
/*=*/ {000000,000000,000000,000000,0x001f,000000,0x001f,000000,000000},
/*>*/ {000000,000000,0x0002,0x0004,0x0008,0x0010,0x0008,0x0004,0x0002},
/*?*/ {000000,000000,0x0004,000000,0x0004,0x0008,0x0010,0x0011,0x000e},
/*@*/ {000000,000000,0x000e,0x0015,0x0015,0x0016,0x0010,0x0011,0x000e},
/*A*/ {000000,000000,0x0011,0x0011,0x001f,0x0011,0x0011,0x000a,0x0004},
/*B*/ {000000,000000,0x000f,0x0012,0x0012,0x000e,0x0012,0x0012,0x000f},
/*C*/ {000000,000000,0x000e,0x0011,0x0001,0x0001,0x0001,0x0011,0x000e},
/*D*/ {000000,000000,0x000f,0x0012,0x0012,0x0012,0x0012,0x0012,0x000f},
/*E*/ {000000,000000,0x001f,0x0001,0x0001,0x0007,0x0001,0x0001,0x001f},
/*F*/ {000000,000000,0x0001,0x0001,0x0001,0x0007,0x0001,0x0001,0x001f},
/*G*/ {000000,000000,0x001e,0x0011,0x0011,0x0019,0x0001,0x0001,0x001e},
/*H*/ {000000,000000,0x0011,0x0011,0x0011,0x001f,0x0011,0x0011,0x0011},
/*I*/ {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0004,0x0004,0x000e},
/*J*/ {000000,000000,0x000e,0x0011,0x0010,0x0010,0x0010,0x0010,0x0010},
/*K*/ {000000,000000,0x0011,0x0009,0x0005,0x0003,0x0005,0x0009,0x0011},
/*L*/ {000000,000000,0x001f,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001},
/*M*/ {000000,000000,0x0011,0x0011,0x0011,0x0015,0x0015,0x001b,0x0011},
/*N*/ {000000,000000,0x0011,0x0011,0x0011,0x0019,0x0015,0x0013,0x0011},
/*O*/ {000000,000000,0x000e,0x0011,0x0011,0x0011,0x0011,0x0011,0x000e},
/*P*/ {000000,000000,0x0001,0x0001,0x0001,0x000f,0x0011,0x0011,0x000f},
/*Q*/ {000000,0x0018,0x000e,0x0015,0x0011,0x0011,0x0011,0x0011,0x000e},
/*R*/ {000000,000000,0x0011,0x0009,0x0005,0x000f,0x0011,0x0011,0x000f},
/*S*/ {000000,000000,0x000e,0x0011,0x0010,0x000e,0x0001,0x0011,0x000e},
/*T*/ {000000,000000,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x001f},
/*U*/ {000000,000000,0x000e,0x0011,0x0011,0x0011,0x0011,0x0011,0x0011},
/*V*/ {000000,000000,0x0004,0x0004,0x000a,0x000a,0x0011,0x0011,0x0011},
/*W*/ {000000,000000,0x0011,0x001b,0x0015,0x0011,0x0011,0x0011,0x0011},
/*X*/ {000000,000000,0x0011,0x0011,0x000a,0x0004,0x000a,0x0011,0x0011},
/*Y*/ {000000,000000,0x0004,0x0004,0x0004,0x0004,0x000a,0x0011,0x0011},
/*Z*/ {000000,000000,0x001f,0x0001,0x0002,0x0004,0x0008,0x0010,0x001f},
/*[*/ {000000,000000,0x000e,0x0002,0x0002,0x0002,0x0002,0x0002,0x000e},
/*\*/ {000000,000000,000000,0x0010,0x0008,0x0004,0x0002,0x0001,000000},
/*]*/ {000000,000000,0x000e,0x0008,0x0008,0x0008,0x0008,0x0008,0x000e},
/*^*/ {000000,000000,000000,000000,000000,000000,0x0011,0x000a,0x0004},
/*_*/ {000000,000000,0x001f,000000,000000,000000,000000,000000,000000},
/*`*/ {000000,000000,000000,000000,000000,0x0008,0x0004,0x000c,0x000c},
/*a*/ {000000,000000,0x001e,0x0011,0x001e,0x0010,0x000e,000000,000000},
/*b*/ {000000,000000,0x000d,0x0013,0x0011,0x0013,0x000d,0x0001,0x0001},
/*c*/ {000000,000000,0x000e,0x0011,0x0001,0x0011,0x000e,000000,000000},
/*d*/ {000000,000000,0x0016,0x0019,0x0011,0x0019,0x0016,0x0010,0x0010},
/*e*/ {000000,000000,0x000e,0x0001,0x001f,0x0011,0x000e,000000,000000},
/*f*/ {000000,000000,0x0004,0x0004,0x0004,0x000e,0x0004,0x0014,0x0008},
/*g*/ {0x000e,0x0011,0x0016,0x0019,0x0011,0x0019,0x0016,000000,000000},
/*h*/ {000000,000000,0x0011,0x0011,0x0011,0x0013,0x000d,0x0001,0x0001},
/*i*/ {000000,000000,0x000e,0x0004,0x0004,0x0004,0x0006,000000,0x0004},
/*j*/ {0x0006,0x0009,0x0008,0x0008,0x0008,0x0008,0x000c,000000,0x0