Skip to content
Permalink
Browse files

Added -define PNG:preserve-colormap option to coders/png.c

  • Loading branch information...
glennrp
glennrp committed Apr 19, 2011
1 parent cc95c3f commit 8d3d6e584829223ac5f6e6653c3caa38a2562a74
Showing with 32 additions and 4 deletions.
  1. +4 −0 ChangeLog
  2. +28 −4 coders/png.c
@@ -1,3 +1,7 @@
2011-04-18 6.6.9-6 Glenn Randers-Pehrson <glennrp@image...>
* Added "-define PNG:preserve-colormap" option (reference
http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18564I)

2011-04-16 6.6.9-6 Cristy <quetzlzacatenango@image...>
* Support the HDR 32-bit_rle_xyze format.
* Added "date" to the things that can appear on the -define PNG:exclude-chunk
@@ -470,7 +470,8 @@ typedef struct _MngInfo
ping_exclude_tRNS,
ping_exclude_vpAg,
ping_exclude_zCCP, /* hex-encoded iCCP */
ping_exclude_zTXt;
ping_exclude_zTXt,
ping_preserve_colormap;

} MngInfo;
#endif /* VER */
@@ -6959,6 +6960,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
ping_exclude_zCCP, /* hex-encoded iCCP */
ping_exclude_zTXt,

ping_preserve_colormap,
ping_need_colortype_warning,

status,
@@ -7010,7 +7012,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,

image = CloneImage(IMimage,0,0,MagickFalse,&IMimage->exception);
image_info=(ImageInfo *) CloneImageInfo(IMimage_info);
if (image == (Image *)NULL || image_info == (ImageInfo *) NULL)
if (image_info == (ImageInfo *) NULL)
ThrowWriterException(ResourceLimitError, "MemoryAllocationFailed");

#if defined(PNG_SETJMP_NOT_THREAD_SAFE)
@@ -7064,6 +7066,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
ping_exclude_zCCP=mng_info->ping_exclude_zCCP; /* hex-encoded iCCP in zTXt */
ping_exclude_zTXt=mng_info->ping_exclude_zTXt;

ping_preserve_colormap = mng_info->ping_preserve_colormap;
ping_need_colortype_warning = MagickFalse;

number_opaque = 0;
@@ -7114,6 +7117,12 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
}
#endif

#if 0 /* To do: Option to use the original colormap */
if (ping_preserve_colormap != MagickFalse)
{
}
#endif

#if 0 /* To do: honor -depth */
if (image->depth < MAGICKCORE_QUANTUM_DEPTH)
{
@@ -7260,8 +7269,9 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" (zero means unknown)");

(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Regenerate the colormap");
if (ping_preserve_colormap == MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Regenerate the colormap");
}

exception=(&image->exception);
@@ -7406,6 +7416,11 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
" image has %d colors",image_colors);
}

#if 1 /* To do */
if (ping_preserve_colormap != MagickFalse)
break;
#endif

if (mng_info->write_png_colortype != 7) /* We won't need this info */
{
ping_have_color=MagickFalse;
@@ -10294,6 +10309,14 @@ static MagickBooleanType WritePNGImage(const ImageInfo *image_info,
mng_info->ping_exclude_zCCP=MagickFalse; /* hex-encoded iCCP in zTXt */
mng_info->ping_exclude_zTXt=MagickFalse;

mng_info->ping_preserve_colormap=MagickFalse;

value=GetImageArtifact(image,"png:preserve-colormap");
if (value == NULL)
value=GetImageOption(image_info,"png:preserve-colormap");
if (value != NULL)
mng_info->ping_preserve_colormap=MagickTrue;

excluding=MagickFalse;

for (source=0; source<1; source++)
@@ -12049,6 +12072,7 @@ static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image)
" Writing PNG object.");

mng_info->need_blob = MagickFalse;
mng_info->ping_preserve_colormap = MagickFalse;

/* We don't want any ancillary chunks written */
mng_info->ping_exclude_bKGD=MagickTrue;

0 comments on commit 8d3d6e5

Please sign in to comment.
You can’t perform that action at this time.