mirror of https://github.com/GNOME/gimp.git
Issue #2997 - Error importing PCX
Commit dc069e424a
removed the
assumption that 1-bpp PCX files are B&W, in favor of using the
provided palette, which is (supposedly?) the correct behavior.
However, there are evidently B&W files that do not specify a
palette, resulting in an all-black image (i.e., a 2-color indexed
image, whose both palette entries are black). Since other
software, including older versions of GIMP, load such files
"correctly", let's fix this by falling back to a B&W palette when
the provded palette is uniform.
This commit is contained in:
parent
bb645bae17
commit
11defa4271
|
@ -469,6 +469,7 @@ load_image (const gchar *filename,
|
|||
|
||||
if (pcx_header.planes == 1 && pcx_header.bpp == 1)
|
||||
{
|
||||
const guint8 *colormap = pcx_header.colormap;
|
||||
dest = g_new (guchar, ((gsize) width) * height);
|
||||
load_1 (fd, width, height, dest, bytesperline);
|
||||
/* Monochrome does not mean necessarily B&W. Therefore we still
|
||||
|
@ -481,7 +482,20 @@ load_image (const gchar *filename,
|
|||
* find counter-examples.
|
||||
* See bug 159947, comment 21 and 23.
|
||||
*/
|
||||
gimp_image_set_colormap (image, pcx_header.colormap, 2);
|
||||
/* ... Actually, there *are* files out there with a zeroed 1-bit palette,
|
||||
* which are supposed to be displayed as B&W (see issue #2997.) These
|
||||
* files *might* be in the wrong (who knows...) but the fact is that
|
||||
* other software, including older versions of GIMP, do display them
|
||||
* "correctly", so let's follow suit: if the two palette colors are
|
||||
* equal, use a B&W palette instead.
|
||||
*/
|
||||
if (! memcmp (colormap, colormap + 3, 3))
|
||||
{
|
||||
static const guint8 bw_colormap[6] = { 0, 0, 0,
|
||||
255, 255, 255};
|
||||
colormap = bw_colormap;
|
||||
}
|
||||
gimp_image_set_colormap (image, colormap, 2);
|
||||
}
|
||||
else if (pcx_header.bpp == 1 && pcx_header.planes == 2)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue