void CSPR::Set1ImageCompressed(BYTE *dat, int no)
{
WORD width, height;
width = *(WORD *)dat;
dat += 2;
height = *(WORD *)dat;
dat += 2;
(imgs+no)->w = width;
(imgs+no)->h = height;
try {
(imgs+no)->dat = (DWORD *)malloc(sizeof(DWORD)*width*height);
(imgs+no)->paldat = (BYTE *)malloc(sizeof(BYTE)*width*height);
} catch (...) {
return;
}
dat += 2; // compressed length
bool zero = false;
int restzero = 0;
int p;
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
p = y*width+x;
if (zero) {
*((imgs+no)->dat + p) = 0;
*((imgs+no)->paldat +p) = 0;
restzero--;
if (restzero == 0) {
zero = false;
}
} else {
if (*dat == 0) {
dat++;
zero = true;
restzero = *dat;
dat++;
*((imgs+no)->dat + p) = 00;
*((imgs+no)->paldat + p) = 0;
restzero--;
if (!restzero) zero = false;
} else {
*((imgs+no)->dat + p) = *(pal + *dat) | 0xFF000000;
*((imgs+no)->paldat + p) = *dat;
dat++;
}
}
}
}
}