Enable RLE coding for PCX output

Pulled from DarkPlaces's lmp2pcx tool, which I have just been made aware
of.
This commit is contained in:
Jeff Teunissen 2011-01-09 03:06:25 -05:00
parent e819ea3b7f
commit af8c1e4cc2

View file

@ -177,15 +177,20 @@ EncodePCX (byte * data, int width, int height,
data += rowbytes * (height - 1); data += rowbytes * (height - 1);
for (i = 0; i < height; i++) { for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) { // from darkplaces lmp2pcx
if ((*data & 0xc0) != 0xc0) for (dataend = data + width; data < dataend; /* empty */) {
*pack++ = *data++; for (pix = *data++, run = 0xC1;
else { data < dataend && run < 0xFF && *data == pix;
*pack++ = 0xc1; data++, run++)
*pack++ = *data++; /* empty */;
} if (run > 0xC1 || pix >= 0xC0)
*pack++ = run;
*pack++ = pix;
} }
if (width & 1)
*pack++ = 0;
data += rowbytes - width; data += rowbytes - width;
if (flip) if (flip)
data -= rowbytes * 2; data -= rowbytes * 2;