mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
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:
parent
e819ea3b7f
commit
af8c1e4cc2
1 changed files with 12 additions and 7 deletions
|
@ -177,15 +177,20 @@ EncodePCX (byte * data, int width, int height,
|
|||
data += rowbytes * (height - 1);
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j++) {
|
||||
if ((*data & 0xc0) != 0xc0)
|
||||
*pack++ = *data++;
|
||||
else {
|
||||
*pack++ = 0xc1;
|
||||
*pack++ = *data++;
|
||||
}
|
||||
// from darkplaces lmp2pcx
|
||||
for (dataend = data + width; data < dataend; /* empty */) {
|
||||
for (pix = *data++, run = 0xC1;
|
||||
data < dataend && run < 0xFF && *data == pix;
|
||||
data++, run++)
|
||||
/* empty */;
|
||||
if (run > 0xC1 || pix >= 0xC0)
|
||||
*pack++ = run;
|
||||
*pack++ = pix;
|
||||
}
|
||||
|
||||
if (width & 1)
|
||||
*pack++ = 0;
|
||||
|
||||
data += rowbytes - width;
|
||||
if (flip)
|
||||
data -= rowbytes * 2;
|
||||
|
|
Loading…
Reference in a new issue