32 return (header->
bpp == 8) && (header->
planes == 3);
53 unsigned int r_mask = 0xF800;
54 unsigned int num_r_bits = 5;
55 unsigned int g_mask = 0x07E0;
56 unsigned int num_g_bits = 6;
57 unsigned int b_mask = 0x001F;
58 unsigned int num_b_bits = 5;
60 unsigned char test_byte;
61 unsigned int row_position;
64 unsigned short *dec_position;
65 unsigned short *temp_dec_position;
72 unsigned int read_offset =
sizeof(
PCXHeader);
73 unsigned short current_line = 0;
75 dec_position = pOutPixels;
77 temp_dec_position = dec_position;
82 test_byte =
input[read_offset];
84 if ((test_byte & 0xC0) == 0xC0) {
88 if ((test_byte & 0x3F) > 0) {
95 << (num_g_bits + num_r_bits +
98 if (row_position == header->
pitch)
break;
99 }
while (
count-- != 1);
103 *temp_dec_position |=
106 << (num_g_bits + num_r_bits + num_b_bits - 8));
109 }
while (row_position < header->pitch);
112 temp_dec_position = dec_position;
115 while (row_position < header->pitch) {
116 test_byte = *(
input + read_offset);
118 if ((test_byte & 0xC0) == 0xC0) {
121 if ((test_byte & 0x3F) > 0) {
122 count = test_byte & 0x3F;
124 *temp_dec_position |=
127 << (num_g_bits + num_b_bits - 8));
131 if (row_position == header->
pitch)
break;
132 }
while (
count-- != 1);
135 *temp_dec_position |=
137 << (num_g_bits + num_b_bits - 8));
143 temp_dec_position = dec_position;
146 while (row_position < header->pitch) {
147 test_byte = *(
input + read_offset);
149 if ((test_byte & 0xC0) == 0xC0) {
152 if ((test_byte & 0x3F) > 0) {
153 count = test_byte & 0x3F;
155 *temp_dec_position |=
value >> (8 - num_b_bits);
159 if (row_position == header->
pitch)
break;
160 }
while (
count-- != 1);
163 *temp_dec_position |= test_byte >> (8 - num_b_bits);
169 dec_position += *
width;
170 }
while (current_line < *
height);
188 header->
pitch = pitch;
205 for (
int i = 0; i < line_size; i++) {
214 *output++ = 0xC0 +
count;
231 for (
int i = 0; i < 16; i++) {
240 for (
int i = 0; i < 16; i++) {
251 :
bytes(bpp / 8),
r(rm),
g(gm),
b(bm) {}
259 unsigned int height,
void *pcx_data,
int max_buff_size,
260 unsigned int *packed_size) {
275 for (
unsigned int x = 0;
x <
width;
x++) {
277 memcpy(&pixel,
input,
f.bytes);
279 lineR[
x] = ((pixel >>
f.r.shift) &
f.r.mask) << (8 -
f.r.bits);
280 lineG[
x] = ((pixel >>
f.g.shift) &
f.g.mask) << (8 -
f.g.bits);
281 lineB[
x] = ((pixel >>
f.b.shift) &
f.b.mask) << (8 -
f.b.bits);
284 for (
int p = 0;
p < 3;
p++) {
292 if (packed_size !=
nullptr) {
293 *packed_size = output - (
uint8_t*)pcx_data;
298 void *pcx_data,
int max_buff_size,
299 unsigned int *packed_size) {
300 Format f(16, 0xF800, 0x07E0, 0x001F);
306 void *pcx_data,
int max_buff_size,
307 unsigned int *packed_size) {
308 Format f(32, 0x00FF0000, 0x0000FF00, 0x000000FF);