mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
images: pcx pcx_width could be smaller that bytes_by_line
Some tools could round up bytes_by_line from pcx_width. Just ignore such cases.
This commit is contained in:
parent
1e0aa094cb
commit
ed286f39e5
1 changed files with 12 additions and 7 deletions
|
@ -265,23 +265,23 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett
|
||||||
if ((pcx->color_planes == 3 || pcx->color_planes == 4)
|
if ((pcx->color_planes == 3 || pcx->color_planes == 4)
|
||||||
&& pcx->bits_per_pixel == 8)
|
&& pcx->bits_per_pixel == 8)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y, linesize;
|
||||||
byte *line;
|
byte *line;
|
||||||
|
|
||||||
if (bytes_per_line <= pcx_width)
|
if (bytes_per_line <= pcx_width)
|
||||||
{
|
{
|
||||||
bytes_per_line = pcx_width + 1;
|
|
||||||
image_issues = true;
|
image_issues = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clean image alpha */
|
/* clean image alpha */
|
||||||
memset(pix, 255, full_size);
|
memset(pix, 255, full_size);
|
||||||
|
|
||||||
line = malloc(bytes_per_line * pcx->color_planes);
|
linesize = Q_max(bytes_per_line, pcx_width + 1) * pcx->color_planes;
|
||||||
|
line = malloc(linesize);
|
||||||
|
|
||||||
for (y = 0; y <= pcx_height; y++, pix += (pcx_width + 1) * 4)
|
for (y = 0; y <= pcx_height; y++, pix += (pcx_width + 1) * 4)
|
||||||
{
|
{
|
||||||
data = PCX_RLE_Decode(line, line + (pcx_width + 1) * pcx->color_planes,
|
data = PCX_RLE_Decode(line, line + linesize,
|
||||||
data, (byte *)pcx + len,
|
data, (byte *)pcx + len,
|
||||||
bytes_per_line * pcx->color_planes, &image_issues);
|
bytes_per_line * pcx->color_planes, &image_issues);
|
||||||
|
|
||||||
|
@ -344,7 +344,8 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett
|
||||||
}
|
}
|
||||||
else if (pcx->color_planes == 1 && pcx->bits_per_pixel == 8)
|
else if (pcx->color_planes == 1 && pcx->bits_per_pixel == 8)
|
||||||
{
|
{
|
||||||
int y;
|
int y, linesize;
|
||||||
|
byte *line;
|
||||||
|
|
||||||
if (palette)
|
if (palette)
|
||||||
{
|
{
|
||||||
|
@ -369,16 +370,20 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett
|
||||||
|
|
||||||
if (bytes_per_line <= pcx_width)
|
if (bytes_per_line <= pcx_width)
|
||||||
{
|
{
|
||||||
bytes_per_line = pcx_width + 1;
|
|
||||||
image_issues = true;
|
image_issues = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linesize = Q_max(bytes_per_line, pcx_width + 1);
|
||||||
|
line = malloc(linesize);
|
||||||
for (y = 0; y <= pcx_height; y++, pix += pcx_width + 1)
|
for (y = 0; y <= pcx_height; y++, pix += pcx_width + 1)
|
||||||
{
|
{
|
||||||
data = PCX_RLE_Decode(pix, pix + pcx_width + 1,
|
data = PCX_RLE_Decode(line, line + linesize,
|
||||||
data, (byte *)pcx + len,
|
data, (byte *)pcx + len,
|
||||||
bytes_per_line, &image_issues);
|
bytes_per_line, &image_issues);
|
||||||
|
/* copy only visible part */
|
||||||
|
memcpy(pix, line, pcx_width + 1);
|
||||||
}
|
}
|
||||||
|
free(line);
|
||||||
}
|
}
|
||||||
else if (pcx->color_planes == 1 &&
|
else if (pcx->color_planes == 1 &&
|
||||||
(pcx->bits_per_pixel == 2 || pcx->bits_per_pixel == 4))
|
(pcx->bits_per_pixel == 2 || pcx->bits_per_pixel == 4))
|
||||||
|
|
Loading…
Reference in a new issue