Diffstat (limited to 'noncore/apps/opie-reader/Palm2QImage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/Palm2QImage.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp index 361755f..09cad1c 100644 --- a/noncore/apps/opie-reader/Palm2QImage.cpp +++ b/noncore/apps/opie-reader/Palm2QImage.cpp | |||
@@ -80,185 +80,185 @@ static ColorMapEntry Palm8BitColormap[] = { | |||
80 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, | 80 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, |
81 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, | 81 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, |
82 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, | 82 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, |
83 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, | 83 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, |
84 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, | 84 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, |
85 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, | 85 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, |
86 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, | 86 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, |
87 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, | 87 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, |
88 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, | 88 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, |
89 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, | 89 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, |
90 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, | 90 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, |
91 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, | 91 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, |
92 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, | 92 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, |
93 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, | 93 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, |
94 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, | 94 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, |
95 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, | 95 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, |
96 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, | 96 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, |
97 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, | 97 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, |
98 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, | 98 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, |
99 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, | 99 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, |
100 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, | 100 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, |
101 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, | 101 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, |
102 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, | 102 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, |
103 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, | 103 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, |
104 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 104 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
105 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 105 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
106 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 106 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
107 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 107 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
108 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 108 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
109 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; | 109 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; |
110 | 110 | ||
111 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; | 111 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; |
112 | 112 | ||
113 | static ColorMapEntry Palm2BitColormap[] = { | 113 | static ColorMapEntry Palm2BitColormap[] = { |
114 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; | 114 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; |
115 | 115 | ||
116 | static ColorMapEntry Palm4BitColormap[] = { | 116 | static ColorMapEntry Palm4BitColormap[] = { |
117 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, | 117 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, |
118 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, | 118 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, |
119 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, | 119 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, |
120 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; | 120 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; |
121 | 121 | ||
122 | QImage* Palm2QImage | 122 | QImage* Palm2QImage |
123 | (unsigned char *image_bytes_in, int byte_count_in) | 123 | (unsigned char *image_bytes_in, int byte_count_in) |
124 | { | 124 | { |
125 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; | 125 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; |
126 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; | 126 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; |
127 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; | 127 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; |
128 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, | 128 | unsigned char *palm_ptr, *x_ptr, *inbyte, *rowbuf, *lastrow, |
129 | *imagedatastart, *palmimage; | 129 | *imagedatastart, *palmimage; |
130 | ColorMapEntry *colormap; | 130 | ColorMapEntry *colormap; |
131 | 131 | ||
132 | palmimage = image_bytes_in; | 132 | palmimage = image_bytes_in; |
133 | width = READ_BIGENDIAN_SHORT(palmimage + 0); | 133 | width = READ_BIGENDIAN_SHORT(palmimage + 0); |
134 | height = READ_BIGENDIAN_SHORT(palmimage + 2); | 134 | height = READ_BIGENDIAN_SHORT(palmimage + 2); |
135 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); | 135 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); |
136 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); | 136 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); |
137 | bits_per_pixel = palmimage[8]; | 137 | bits_per_pixel = palmimage[8]; |
138 | version = palmimage[9]; | 138 | version = palmimage[9]; |
139 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); | 139 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); |
140 | transparent_index = palmimage[12]; | 140 | transparent_index = palmimage[12]; |
141 | compression_type = palmimage[13]; | 141 | compression_type = palmimage[13]; |
142 | /* bytes 14 and 15 are reserved by Palm and always 0 */ | 142 | /* bytes 14 and 15 are reserved by Palm and always 0 */ |
143 | 143 | ||
144 | #if 0 | 144 | #if 0 |
145 | // qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); | 145 | // qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); |
146 | #endif | 146 | #endif |
147 | 147 | ||
148 | if (compression_type == PALM_COMPRESSION_PACKBITS) { | 148 | if (compression_type == PALM_COMPRESSION_PACKBITS) { |
149 | // qDebug ("Image uses packbits compression; not yet supported"); | 149 | // qDebug ("Image uses packbits compression; not yet supported"); |
150 | return NULL; | 150 | return NULL; |
151 | } else if ((compression_type != PALM_COMPRESSION_NONE) && | 151 | } else if ((compression_type != PALM_COMPRESSION_NONE) && |
152 | (compression_type != PALM_COMPRESSION_RLE) && | 152 | (compression_type != PALM_COMPRESSION_RLE) && |
153 | (compression_type != PALM_COMPRESSION_SCANLINE)) { | 153 | (compression_type != PALM_COMPRESSION_SCANLINE)) { |
154 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); | 154 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); |
155 | return NULL; | 155 | return NULL; |
156 | } | 156 | } |
157 | 157 | ||
158 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: | 158 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: |
159 | 159 | ||
160 | 1, 2, or 4 bit grayscale | 160 | 1, 2, or 4 bit grayscale |
161 | 8-bit StaticColor using the Palm standard colormap | 161 | 8-bit StaticColor using the Palm standard colormap |
162 | 8-bit PseudoColor using a user-specified colormap | 162 | 8-bit PseudoColor using a user-specified colormap |
163 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue | 163 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue |
164 | 164 | ||
165 | Each of these can be compressed with one of four compression schemes, | 165 | Each of these can be compressed with one of four compression schemes, |
166 | "RLE", "Scanline", "PackBits", or none. | 166 | "RLE", "Scanline", "PackBits", or none. |
167 | 167 | ||
168 | We begin by constructing the colormap. | 168 | We begin by constructing the colormap. |
169 | */ | 169 | */ |
170 | 170 | ||
171 | if (flags & PALM_HAS_COLORMAP_FLAG) { | 171 | if (flags & PALM_HAS_COLORMAP_FLAG) { |
172 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); | 172 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); |
173 | return NULL; | 173 | return NULL; |
174 | } else if (bits_per_pixel == 1) { | 174 | } else if (bits_per_pixel == 1) { |
175 | colormap = Palm1BitColormap; | 175 | colormap = Palm1BitColormap; |
176 | imagedatastart = palmimage + 16; | 176 | imagedatastart = palmimage + 16; |
177 | } else if (bits_per_pixel == 2) { | 177 | } else if (bits_per_pixel == 2) { |
178 | colormap = Palm2BitColormap; | 178 | colormap = Palm2BitColormap; |
179 | imagedatastart = palmimage + 16; | 179 | imagedatastart = palmimage + 16; |
180 | } else if (bits_per_pixel == 4) { | 180 | } else if (bits_per_pixel == 4) { |
181 | colormap = Palm4BitColormap; | 181 | colormap = Palm4BitColormap; |
182 | imagedatastart = palmimage + 16; | 182 | imagedatastart = palmimage + 16; |
183 | } else if (bits_per_pixel == 8) { | 183 | } else if (bits_per_pixel == 8) { |
184 | colormap = Palm8BitColormap; | 184 | colormap = Palm8BitColormap; |
185 | imagedatastart = palmimage + 16; | 185 | imagedatastart = palmimage + 16; |
186 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { | 186 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { |
187 | colormap = NULL; | 187 | colormap = NULL; |
188 | palm_red_bits = palmimage[16]; | 188 | palm_red_bits = palmimage[16]; |
189 | palm_green_bits = palmimage[17]; | 189 | palm_green_bits = palmimage[17]; |
190 | palm_blue_bits = palmimage[18]; | 190 | palm_blue_bits = palmimage[18]; |
191 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); | 191 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); |
192 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { | 192 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { |
193 | // qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); | 193 | // qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); |
194 | return NULL; | 194 | return NULL; |
195 | } | 195 | } |
196 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { | 196 | if (bits_per_pixel > (8 * sizeof(unsigned long))) { |
197 | // qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); | 197 | // qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); |
198 | return NULL; | 198 | return NULL; |
199 | } | 199 | } |
200 | imagedatastart = palmimage + 24; | 200 | imagedatastart = palmimage + 24; |
201 | } else { | 201 | } else { |
202 | // qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); | 202 | // qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); |
203 | return NULL; | 203 | return NULL; |
204 | } | 204 | } |
205 | 205 | ||
206 | #ifndef USEQPE | 206 | #ifndef USEQPE |
207 | QImage* qimage = new QImage(width, height, 32); | 207 | QImage* qimage = new QImage(width, height, 32); |
208 | #else | 208 | #else |
209 | QImage* qimage = new QImage(width, height, 16); | 209 | QImage* qimage = new QImage(width, height, 16); |
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ | 212 | /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ |
213 | rowbuf = new unsigned char[bytes_per_row * width]; | 213 | rowbuf = new unsigned char[bytes_per_row * width]; |
214 | lastrow = new unsigned char[bytes_per_row * width]; | 214 | lastrow = new unsigned char[bytes_per_row * width]; |
215 | 215 | ||
216 | for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { | 216 | for (i=0, palm_ptr = imagedatastart , x_ptr = 0; i < height; ++i) { |
217 | // qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); | 217 | // qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); |
218 | 218 | ||
219 | /* first, uncompress the Palm image */ | 219 | /* first, uncompress the Palm image */ |
220 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { | 220 | if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { |
221 | for (j = 0; j < bytes_per_row; ) { | 221 | for (j = 0; j < bytes_per_row; ) { |
222 | incount = *palm_ptr++; | 222 | incount = *palm_ptr++; |
223 | inval = *palm_ptr++; | 223 | inval = *palm_ptr++; |
224 | memset(rowbuf + j, inval, incount); | 224 | memset(rowbuf + j, inval, incount); |
225 | j += incount; | 225 | j += incount; |
226 | } | 226 | } |
227 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { | 227 | } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { |
228 | for (j = 0; j < bytes_per_row; j += 8) { | 228 | for (j = 0; j < bytes_per_row; j += 8) { |
229 | incount = *palm_ptr++; | 229 | incount = *palm_ptr++; |
230 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; | 230 | inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; |
231 | for (inbit = 0; inbit < inval; inbit += 1) { | 231 | for (inbit = 0; inbit < inval; inbit += 1) { |
232 | if (incount & (1 << (7 - inbit))) | 232 | if (incount & (1 << (7 - inbit))) |
233 | rowbuf[j + inbit] = *palm_ptr++; | 233 | rowbuf[j + inbit] = *palm_ptr++; |
234 | else | 234 | else |
235 | rowbuf[j + inbit] = lastrow[j + inbit]; | 235 | rowbuf[j + inbit] = lastrow[j + inbit]; |
236 | } | 236 | } |
237 | } | 237 | } |
238 | memcpy (lastrow, rowbuf, bytes_per_row); | 238 | memcpy (lastrow, rowbuf, bytes_per_row); |
239 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && | 239 | } else if (((flags & PALM_IS_COMPRESSED_FLAG) && |
240 | (compression_type == PALM_COMPRESSION_NONE)) || | 240 | (compression_type == PALM_COMPRESSION_NONE)) || |
241 | ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) | 241 | ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) |
242 | { | 242 | { |
243 | memcpy (rowbuf, palm_ptr, bytes_per_row); | 243 | memcpy (rowbuf, palm_ptr, bytes_per_row); |
244 | palm_ptr += bytes_per_row; | 244 | palm_ptr += bytes_per_row; |
245 | } | 245 | } |
246 | else { | 246 | else { |
247 | qDebug("Case 4"); | 247 | qDebug("Case 4"); |
248 | qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); | 248 | qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); |
249 | qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); | 249 | qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); |
250 | qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); | 250 | qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); |
251 | qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); | 251 | qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); |
252 | qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); | 252 | qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); |
253 | memcpy (rowbuf, palm_ptr, bytes_per_row); | 253 | memcpy (rowbuf, palm_ptr, bytes_per_row); |
254 | palm_ptr += bytes_per_row; | 254 | palm_ptr += bytes_per_row; |
255 | } | 255 | } |
256 | /* next, write it to the GDK bitmap */ | 256 | /* next, write it to the GDK bitmap */ |
257 | if (colormap) { | 257 | if (colormap) { |
258 | mask = (1 << bits_per_pixel) - 1; | 258 | mask = (1 << bits_per_pixel) - 1; |
259 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { | 259 | for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { |
260 | inval = ((*inbyte) & (mask << inbit)) >> inbit; | 260 | inval = ((*inbyte) & (mask << inbit)) >> inbit; |
261 | /* correct for oddity of the 8-bit color Palm pixmap... */ | 261 | /* correct for oddity of the 8-bit color Palm pixmap... */ |
262 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; | 262 | if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; |
263 | /* now lookup the correct color and set the pixel in the GTK bitmap */ | 263 | /* now lookup the correct color and set the pixel in the GTK bitmap */ |
264 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); | 264 | QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); |