Commit 1c30c4ae authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

allow to save images that are plain white or plain black using the CCITT

2008-12-03  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/file-tiff-save.c (save_image)
	(image_is_monochrome): allow to save images that are plain white 
or
	plain black using the CCITT Fax compression methods.


svn path=/trunk/; revision=27756
parent 0e3acdcc
2008-12-03 Sven Neumann <sven@gimp.org>
* plug-ins/common/file-tiff-save.c (save_image)
(image_is_monochrome): allow to save images that are plain white or
plain black using the CCITT Fax compression methods.
2008-12-03 Sven Neumann <sven@gimp.org>
* plug-ins/common/file-ps.c: minor cleanup.
......
......@@ -425,13 +425,13 @@ image_is_monochrome (gint32 image)
if (colors)
{
if (num_colors == 2)
if (num_colors == 2 || num_colors == 1)
{
const guchar bw_map[] = { 0, 0, 0, 255, 255, 255 };
const guchar wb_map[] = { 255, 255, 255, 0, 0, 0 };
const guchar bw_map[] = { 0, 0, 0, 255, 255, 255 };
const guchar wb_map[] = { 255, 255, 255, 0, 0, 0 };
if (memcmp (colors, bw_map, 6) == 0 ||
memcmp (colors, wb_map, 6) == 0)
if (memcmp (colors, bw_map, 3 * num_colors) == 0 ||
memcmp (colors, wb_map, 3 * num_colors) == 0)
{
monochrome = TRUE;
}
......@@ -649,7 +649,7 @@ save_image (const gchar *filename,
gint bytesperrow;
guchar *t, *src, *data;
guchar *cmap;
gint colors;
gint num_colors;
gint success;
GimpDrawable *drawable;
GimpImageType drawable_type;
......@@ -740,16 +740,16 @@ save_image (const gchar *filename,
break;
case GIMP_INDEXED_IMAGE:
cmap = gimp_image_get_colormap (image, &colors);
cmap = gimp_image_get_colormap (image, &num_colors);
if (colors == 2)
if (num_colors == 2 || num_colors == 1)
{
is_bw = (memcmp (cmap, bw_map, 6) == 0);
is_bw = (memcmp (cmap, bw_map, 3 * num_colors) == 0);
photometric = PHOTOMETRIC_MINISWHITE;
if (!is_bw)
{
is_bw = (memcmp (cmap, wb_map, 6) == 0);
is_bw = (memcmp (cmap, wb_map, 3 * num_colors) == 0);
if (is_bw)
invert = FALSE;
......@@ -765,7 +765,7 @@ save_image (const gchar *filename,
bitspersample = 8;
photometric = PHOTOMETRIC_PALETTE;
for (i = 0; i < colors; i++)
for (i = 0; i < num_colors; i++)
{
red[i] = cmap[i * 3 + 0] * 65535 / 255;
grn[i] = cmap[i * 3 + 1] * 65535 / 255;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment