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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
$NetBSD: patch-aa,v 1.2 1999/05/26 23:11:41 tron Exp $
--- x11.c.orig Tue Nov 11 09:14:40 1997
+++ x11.c Tue Nov 11 09:23:59 1997
@@ -62,6 +62,9 @@
#define MONO_32 (5)
#define COLOR_32 (6)
+#define MONO_24 (7)
+#define COLOR_24 (9)
+
#define LABEL_LEFT_FLUSH (1<<0)
#define LABEL_TOP_FLUSH (1<<1)
@@ -76,6 +79,7 @@
static void pack_mono_1 _P((u16or32 *, u_char *));
static void pack_8 _P((u16or32 *, Pixel *, u_char *));
static void pack_16 _P((u16or32 *, Pixel *, u_char *));
+static void pack_24 _P((u16or32 *, Pixel *, u_char *));
static void pack_32 _P((u16or32 *, Pixel *, u_char *));
static void x11_row _P((u_char *));
static void x11_cleanup _P((void));
@@ -358,6 +362,11 @@
case 24:
/* try to pack ximage data 32 bits/pixel */
+ x_type = mono ? MONO_24 : COLOR_24;
+ break;
+
+ case 32:
+ /* try to pack ximage data 32 bits/pixel */
x_type = mono ? MONO_32 : COLOR_32;
break;
@@ -376,6 +385,7 @@
case MONO_1:
case MONO_8:
case MONO_16:
+ case MONO_24:
case MONO_32:
mono_dither_setup();
pels = (Pixel *) malloc((unsigned) sizeof(Pixel) * 2);
@@ -386,6 +396,7 @@
case COLOR_8:
case COLOR_16:
+ case COLOR_24:
case COLOR_32:
if (XAllocNamedColor(dsply, cmap, "red", &xc, &junk) != 0)
hlight = xc.pixel;
@@ -689,6 +700,14 @@
bits_per_pixel = 16;
break;
+ /* added this. -wsr */
+ case MONO_24:
+ case COLOR_24:
+ dith_size = wdth;
+ xbuf_size = dith_size * 3;
+ bits_per_pixel = 24;
+ break;
+
case MONO_32:
case COLOR_32:
dith_size = wdth;
@@ -817,6 +836,43 @@
}
+/* pack pixels into ximage format (assuming bits_per_pixel == 24)
+ */
+static void pack_24(src, map, dst)
+ u16or32 *src;
+ Pixel *map;
+ u_char *dst;
+{
+ int i, i_lim;
+ unsigned val;
+
+ i_lim = wdth;
+
+ if (xim->byte_order == MSBFirst)
+ {
+ for (i=0; i<i_lim; i++)
+ {
+ val = map[src[i]];
+ dst[0] = (val >> 16) & 0xff;
+ dst[1] = (val >> 8) & 0xff;
+ dst[2] = val & 0xff;
+ dst += 3;
+ }
+ }
+ else /* (xim->byte_order == LSBFirst) */
+ {
+ for (i=0; i<i_lim; i++)
+ {
+ val = map[src[i]];
+ dst[0] = val & 0xff;
+ dst[1] = (val >> 8) & 0xff;
+ dst[2] = (val >> 16) & 0xff;
+ dst += 3;
+ }
+ }
+}
+
+
/* pack pixels into ximage format (assuming bits_per_pixel == 32)
*/
static void pack_32(src, map, dst)
@@ -876,6 +932,11 @@
pack_16(dith, pels, xbuf);
break;
+ case MONO_24:
+ mono_dither_row(row, dith);
+ pack_24(dith, pels, xbuf);
+ break;
+
case MONO_32:
mono_dither_row(row, dith);
pack_32(dith, pels, xbuf);
@@ -889,6 +950,11 @@
case COLOR_16:
dither_row(row, dith);
pack_16(dith, pels, xbuf);
+ break;
+
+ case COLOR_24:
+ dither_row(row, dith);
+ pack_24(dith, pels, xbuf);
break;
case COLOR_32:
|