aboutsummaryrefslogtreecommitdiff
path: root/images.c
blob: e8ca33fdfa7aeee91d41f5b3b07d3d0ada312ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* Copyright 1998 DJ Delorie <dj@delorie.com>
   Distributed under the terms of the GNU GPL
   http://www.delorie.com/store/hcalc/
   Revisions copyright 2007,  
   Theodore Kilgore <kilgota@auburn.edu>
	More revisions copyright 2023, B. Watson <urchlay@slackware.uk>
*/
#include "hcalc.h"
#include <X11/xpm.h>

#define xpm face0_data
#include "xpm/face.xpm"
#undef xpm
#define xpm face1_data
#include "xpm/face.250.xpm"
#undef xpm
#define xpm face2_data
#include "xpm/face.500.xpm"
#undef xpm

#define xpm chars0_data
#include "xpm/chars.xpm"
#undef xpm
#define xpm chars1_data
#include "xpm/chars.250.xpm"
#undef xpm
#define xpm chars2_data
#include "xpm/chars.500.xpm"
#undef xpm

static char **faces[3] = { face0_data, face1_data, face2_data };
static char **charss[3] = { chars0_data, chars1_data, chars2_data };
static int c_factors[3] = { 6, 12, 24 };

Pixmap face;
Pixmap chars;

char charmap[] = " 0123456789ABCDEF-x,.ro+";
int char_to_x[256];

void free_pixmaps(void) {
	if(face) XFreePixmap(display, face);
	if(chars) XFreePixmap(display, chars);
}

void load_pixmaps(void) {
	int i, c;

	XpmAttributes attr;
	attr.valuemask = 0;
	XpmCreatePixmapFromData(display, window, faces[winsize], &face, 0,
							&attr);
	XpmCreatePixmapFromData(display, window, charss[winsize], &chars, 0,
							&attr);

	for(i = 0; i < 256; i++) {
		char_to_x[i] = 0;
		for(c = 0; charmap[c]; c++)
			if(charmap[c] == i) {
				char_to_x[i] = c * c_factors[winsize];
				/* printf("char_to_x[%d] ('%c') = %d\n", i, i, c*C_FACTOR); */
			}
	}
}