- fclose(file);
-
- pcx.signature = file_buffer[0];
- pcx.version = file_buffer[1];
- pcx.encoding = file_buffer[2];
- pcx.bits_per_pixel = file_buffer[3];
- pcx.xmin = file_buffer[4] + 256 * file_buffer[5];
- pcx.ymin = file_buffer[6] + 256 * file_buffer[7];
- pcx.xmax = file_buffer[8] + 256 * file_buffer[9];
- pcx.ymax = file_buffer[10] + 256 * file_buffer[11];
- pcx.color_planes = file_buffer[65];
- pcx.bytes_per_line = file_buffer[66] + 256 * file_buffer[67];
- pcx.palette_type = file_buffer[68] + 256 * file_buffer[69];
+ pcx.signature = header_buffer[0];
+ pcx.version = header_buffer[1];
+ pcx.encoding = header_buffer[2];
+ pcx.bits_per_pixel = header_buffer[3];
+ pcx.xmin = (header_buffer[5] << 8) | header_buffer[4];
+ pcx.ymin = (header_buffer[7] << 8) | header_buffer[6];
+ pcx.xmax = (header_buffer[9] << 8) | header_buffer[8];
+ pcx.ymax = (header_buffer[11] << 8) | header_buffer[10];
+ pcx.color_planes = header_buffer[65];
+ pcx.bytes_per_line = (header_buffer[67] << 8) | header_buffer[66];
+ pcx.palette_type = (header_buffer[69] << 8) | header_buffer[68];
+
+ for (i = 0; i < 48; i++)
+ pcx.palette[i / 3][i % 3] = header_buffer[16 + i];