mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
images: support 24 bit pcx images
This commit is contained in:
parent
66da110472
commit
84e461e07b
1 changed files with 41 additions and 6 deletions
|
@ -223,8 +223,11 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett
|
|||
pcx_width = pcx->xmax - pcx->xmin;
|
||||
pcx_height = pcx->ymax - pcx->ymin;
|
||||
|
||||
if ((pcx->manufacturer != 0x0a) || (pcx->version != 5) ||
|
||||
(pcx->encoding != 1) || (pcx->bits_per_pixel != 8))
|
||||
if ((pcx->manufacturer != 0x0a) ||
|
||||
(pcx->version != 5) ||
|
||||
(pcx->encoding != 1) ||
|
||||
((pcx->color_planes != 1) && (pcx->color_planes != 3)) ||
|
||||
(pcx->bits_per_pixel != 8))
|
||||
{
|
||||
Com_Printf("%s: Bad pcx file %s\n", __func__, name);
|
||||
return;
|
||||
|
@ -237,6 +240,12 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett
|
|||
}
|
||||
|
||||
full_size = (pcx_height + 1) * (pcx_width + 1);
|
||||
if (pcx->color_planes == 3)
|
||||
{
|
||||
full_size *= 4;
|
||||
*bitesPerPixel = 32;
|
||||
}
|
||||
|
||||
out = malloc(full_size);
|
||||
if (!out)
|
||||
{
|
||||
|
@ -277,12 +286,38 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett
|
|||
*height = pcx_height + 1;
|
||||
}
|
||||
|
||||
if (pcx->color_planes == 3)
|
||||
{
|
||||
int x, y;
|
||||
byte *line;
|
||||
|
||||
line = malloc(pcx->bytes_per_line * pcx->color_planes);
|
||||
|
||||
for (y = 0; y <= pcx_height; y++, pix += (pcx_width + 1) * 4)
|
||||
{
|
||||
raw = PCX_RLE_Decode(line, line + (pcx_width + 1) * pcx->color_planes,
|
||||
raw, (byte *)pcx + len,
|
||||
pcx->bytes_per_line * pcx->color_planes);
|
||||
|
||||
for (x = 0; x < pcx_width + 1; x++) {
|
||||
pix[4 * x + 0] = line[x];
|
||||
pix[4 * x + 1] = line[x + pcx->bytes_per_line];
|
||||
pix[4 * x + 2] = line[x + pcx->bytes_per_line * 2];
|
||||
pix[4 * x + 3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
free(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = 0; y <= pcx_height; y++, pix += pcx_width + 1)
|
||||
{
|
||||
raw = PCX_RLE_Decode(pix, pix + pcx_width + 1,
|
||||
raw, (byte *)pcx + len,
|
||||
pcx->bytes_per_line);
|
||||
}
|
||||
}
|
||||
|
||||
if (raw - (byte *)pcx > len)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue