25 #define MAX_SIZE (4*1024*1024)
32 : width(0), height(0), bitmap(0), himap(0), imagebytes(0)
105 for (
unsigned int i = 0; i < 58; i++)
115 for (
unsigned long i = 0; i <
imagebytes; i++)
118 unsigned char* p =
pal;
119 for (
int i = 0; i < 256; i++) {
129 : bitmap(0), himap(0)
198 for (
unsigned int i = 0; i < 58; i++)
208 for (
unsigned long i = 0; i <
imagebytes; i++)
209 himap[i] = hibits[i];
225 unsigned char abyte, *p;
228 fopen_s(&f, filename,
"rb");
244 fseek(f,-768L,SEEK_END);
260 unsigned long* pix =
himap;
266 bytecount = abyte & 0x3f;
272 else if (--bytecount == 0) {
276 *pix++ = 0xff000000 | (
pal[3*abyte] << 16) | (
pal[3*abyte+1] << 8) | (
pal[3*abyte+2]);
299 for (
int row = 0; row <
height; row++) {
301 for (
int plane = 2; plane >= 0; plane--) {
302 p = ((
unsigned char*)
himap) +
width*row*4 + plane;
303 for (
int col = 0; col <
width; col++) {
308 bytecount = abyte & 0x3f;
314 else if (--bytecount == 0) {
335 unsigned char abyte, *p;
355 memcpy(
pal,buf+len-768,768);
366 unsigned long* pix =
himap;
372 bytecount = abyte & 0x3f;
378 else if (--bytecount == 0) {
382 *pix++ = 0xff000000 | (
pal[3*abyte] << 16) | (
pal[3*abyte+1] << 8) | (
pal[3*abyte+2]);
404 for (
int row = 0; row <
height; row++) {
406 for (
int plane = 2; plane >= 0; plane--) {
407 p = ((
unsigned char*)
himap) +
width*row*4 + plane;
408 for (
int col = 0; col <
width; col++) {
413 bytecount = abyte & 0x3f;
419 else if (--bytecount == 0) {
440 fopen_s(&f, filename,
"wb");
447 unsigned char *p =
bitmap;
449 unsigned long row = 0;
450 unsigned char palette_marker = 12;
453 unsigned char* start = p;
454 unsigned char count = 0;
456 while (*start == *p && count < 0x3f && row <
width) {
462 if (count > 1 || *start > 0xbf) {
469 fwrite(start, 1, 1, f);
478 fwrite(&palette_marker,1,1,f);
484 for (
int row = 0; row <
height; row++) {
485 for (
int plane = 2; plane >= 0; plane--) {
486 unsigned long col = 0;
487 unsigned char* p = ((
unsigned char*)
himap) +
width*row*4 + plane;
489 while (col <
width) {
490 unsigned char* start = p;
491 unsigned char count = 0;
493 while (*start == *p && count < 0x3f && col <
width) {
499 if (count > 1 || *start > 0xbf) {
506 fwrite(start, 1, 1, f);