*
* This is true if the high byte and the next highest byte of
* each sample of the image, the colormap, and the background color
- * are equal to each other. We check this by seeing if the samples
- * are unchanged when we scale them down to 8 and back up to Quantum.
+ * are equal to each other.
*
* We don't use the method GetImageDepth() because it doesn't check
- * background and doesn't handle PseudoClass specially.
+ * background * and doesn't handle PseudoClass specially. Also
+ * GetImageDepth() uses multiplication and division by 257 instead of
+ * shifting, so it might be slower.
*/
-#define ScaleQuantumToCharToQuantum(quantum) \
- (ScaleCharToQuantum((unsigned char) ScaleQuantumToChar(quantum)))
-
MagickBooleanType
ok_to_reduce=MagickFalse;
const PixelPacket
*p;
+ const int
+ pnghi= MAGICKCORE_QUANTUM_DEPTH - 8,
+ pnglo= MAGICKCORE_QUANTUM_DEPTH - 16;
+
ok_to_reduce=
- (image->background_color.red ==
- ScaleQuantumToCharToQuantum(image->background_color.red) &&
- image->background_color.green ==
- ScaleQuantumToCharToQuantum(image->background_color.green) &&
- image->background_color.blue ==
- ScaleQuantumToCharToQuantum(image->background_color.blue)) ?
+ (((((size_t) image->background_color.red >> pnghi) & 0xff)
+ == (((size_t) image->background_color.red >> pnglo) & 0xff)) &&
+ ((((size_t) image->background_color.green >> pnghi) & 0xff)
+ == (((size_t) image->background_color.green >> pnglo) & 0xff)) &&
+ ((((size_t) image->background_color.blue >> pnghi) & 0xff)
+ == (((size_t) image->background_color.blue >> pnglo) & 0xff))) ?
MagickTrue : MagickFalse;
if (ok_to_reduce != MagickFalse && image->storage_class == PseudoClass)
for (indx=0; indx < (ssize_t) image->colors; indx++)
{
- ok_to_reduce=(
- image->colormap[indx].red ==
- ScaleQuantumToCharToQuantum(image->colormap[indx].red) &&
- image->colormap[indx].green ==
- ScaleQuantumToCharToQuantum(image->colormap[indx].green) &&
- image->colormap[indx].blue ==
- ScaleQuantumToCharToQuantum(image->colormap[indx].blue) &&
- (image->matte == MagickFalse ||
- image->colormap[indx].opacity ==
- ScaleQuantumToCharToQuantum(image->colormap[indx].opacity)))
- ? MagickTrue : MagickFalse;
-
+ ok_to_reduce=
+ (((((size_t) image->colormap[indx].red >> pnghi) & 0xff)
+ == (((size_t) image->colormap[indx].red >> pnglo) & 0xff)) &&
+ ((((size_t) image->colormap[indx].green >> pnghi) & 0xff)
+ == (((size_t) image->colormap[indx].green >> pnglo) & 0xff))
+ && ((((size_t) image->colormap[indx].blue >> pnghi) & 0xff)
+ == (((size_t) image->colormap[indx].blue >> pnglo) & 0xff)) &&
+ (image->matte == MagickFalse ||
+ (((size_t) image->colormap[indx].opacity >> pnghi) & 0xff)
+ == (((size_t) image->colormap[indx].opacity >> pnglo)
+ & 0xff))) ? MagickTrue : MagickFalse;
if (ok_to_reduce == MagickFalse)
- break;
+ break;
}
}
for (x=(ssize_t) image->columns-1; x >= 0; x--)
{
- ok_to_reduce=
- (GetRedPixelComponent(p) ==
- ScaleQuantumToCharToQuantum(GetRedPixelComponent(p)) &&
- GetGreenPixelComponent(p) ==
- ScaleQuantumToCharToQuantum(GetGreenPixelComponent(p)) &&
- GetBluePixelComponent(p) ==
- ScaleQuantumToCharToQuantum(GetBluePixelComponent(p)) &&
- (image->matte == MagickFalse ||
- GetOpacityPixelComponent(p)
- == ScaleQuantumToCharToQuantum(GetOpacityPixelComponent(p))))
- ? MagickTrue : MagickFalse;
+ ok_to_reduce=(
+ ((((size_t) p->red >> pnghi) & 0xff) ==
+ (((size_t) p->red >> pnglo) & 0xff)) &&
+ ((((size_t) p->green >> pnghi) & 0xff) ==
+ (((size_t) p->green >> pnglo) & 0xff)) &&
+ ((((size_t) p->blue >> pnghi) & 0xff) ==
+ (((size_t) p->blue >> pnglo) & 0xff)) &&
+ (((image->matte == MagickFalse ||
+ (((size_t) p->opacity >> pnghi) & 0xff) ==
+ (((size_t) p->opacity >> pnglo) & 0xff))))) ?
+ MagickTrue : MagickFalse;
if (ok_to_reduce == MagickFalse)
break;
if (q == (PixelPacket *) NULL)
break;
+#if (0 && (MAGICKCORE_QUANTUM_DEPTH == 8) && !defined(MAGICKCORE_HDRI_SUPPORT))
+/* code deleted from version 6.6.6-8 */
+#else /* (MAGICKCORE_QUANTUM_DEPTH != 8) */
+
if ((int) ping_color_type == PNG_COLOR_TYPE_GRAY)
(void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
GrayQuantum,ping_pixels+row_offset,exception);
else /* ping_color_type == PNG_COLOR_TYPE_RGB */
(void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
RGBQuantum,ping_pixels+row_offset,exception);
-
+#endif
if (found_transparent_pixel == MagickFalse)
{
/* Is there a transparent pixel in the row? */
for (x=(ssize_t) image->columns-7; x > 0; x-=8)
{
for (bit=7; bit >= 0; bit--)
- *r++=ScaleCharToQuantum(
- (unsigned char) ((*p) & (0x01 << bit) ? 0xff : 0x00));
+ *r++=(Quantum) ((*p) & (0x01 << bit) ? 0x01 : 0x00);
p++;
}
if ((image->columns % 8) != 0)
{
for (bit=7; bit >= (ssize_t) (8-(image->columns % 8)); bit--)
- *r++=ScaleCharToQuantum(
- (unsigned char) ((*p) & (0x01 << bit) ? 0xff : 0x00));
+ *r++=(Quantum) ((*p) & (0x01 << bit) ? 0x01 : 0x00);
}
break;
{
for (x=(ssize_t) image->columns-3; x > 0; x-=4)
{
- *r++=ScaleCharToQuantum((unsigned char) (0x55*(*p >> 6) & 0x03));
- *r++=ScaleCharToQuantum((unsigned char) (0x55*(*p >> 4) & 0x03));
- *r++=ScaleCharToQuantum((unsigned char) (0x55*(*p >> 2) & 0x03));
- *r++=ScaleCharToQuantum((unsigned char) (0x55*(*p++) & 0x03));
+ *r++=(*p >> 6) & 0x03;
+ *r++=(*p >> 4) & 0x03;
+ *r++=(*p >> 2) & 0x03;
+ *r++=(*p++) & 0x03;
}
if ((image->columns % 4) != 0)
{
for (i=3; i >= (ssize_t) (4-(image->columns % 4)); i--)
- *r++=ScaleCharToQuantum((unsigned char)
- (0x55*((*p >> (i*2)) & 0x03)));
+ *r++=(Quantum) ((*p >> (i*2)) & 0x03);
}
break;
{
for (x=(ssize_t) image->columns-1; x > 0; x-=2)
{
- *r++=ScaleCharToQuantum((unsigned char) (0x11*(*p >> 4) & 0x0f));
- *r++=ScaleCharToQuantum((unsigned char) (0x11*(*p++) & 0x0f));
+ *r++=(*p >> 4) & 0x0f;
+ *r++=(*p++) & 0x0f;
}
if ((image->columns % 2) != 0)
- *r++=ScaleCharToQuantum((unsigned char) (0x11*(*p >> 4) & 0x0f));
+ *r++=(*p++ >> 4) & 0x0f;
break;
}
if (ping_color_type == 4)
for (x=(ssize_t) image->columns-1; x >= 0; x--)
{
- *r++=ScaleCharToQuantum((unsigned char) *p++);
+ *r++=*p++;
/* In image.h, OpaqueOpacity is 0
* TransparentOpacity is QuantumRange
* In a PNG datastream, Opaque is QuantumRange
else
for (x=(ssize_t) image->columns-1; x >= 0; x--)
- *r++=ScaleCharToQuantum((unsigned char) *p++);
+ *r++=*p++;
break;
}
{
for (x=(ssize_t) image->columns-1; x >= 0; x--)
{
-#if MAGICKCORE_QUANTUM_DEPTH == 8
- *r++=*p++;
- p++; /* skip low byte */
+#if (MAGICKCORE_QUANTUM_DEPTH == 16)
+ size_t
+ quantum;
+
+ if (image->colors > 256)
+ *r=((*p++) << 8);
+
+ else
+ *r=0;
+
+ quantum=(*r);
+ quantum|=(*p++);
+ *r=(Quantum) quantum;
+ r++;
if (ping_color_type == 4)
{
- q->opacity=(Quantum) (QuantumRange - *p++);
+ quantum=((*p++) << 8);
+ quantum|=(*p++);
+ q->opacity=(Quantum) (QuantumRange-quantum);
if (q->opacity != OpaqueOpacity)
found_transparent_pixel = MagickTrue;
- p++;
q++;
}
+#else
+#if (MAGICKCORE_QUANTUM_DEPTH == 32)
+ size_t
+ quantum;
-#else /* MAGICKCORE_QUANTUM_DEPTH >= 16 */
- *r++ = ScaleShortToQuantum(
- (unsigned short) (((*p) << 8) | (*(p+1))));
- p+=2;
+ if (image->colors > 256)
+ *r=((*p++) << 8);
+
+ else
+ *r=0;
+
+ quantum=(*r);
+ quantum|=(*p++);
+ *r=quantum;
+ r++;
if (ping_color_type == 4)
{
- q->opacity = QuantumRange - ScaleShortToQuantum(
- (unsigned short) (((*p) << 8) | (*(p+1))));
+ q->opacity=(*p << 8) | *(p+1);
+ q->opacity*=65537L;
+ q->opacity=(Quantum) GetAlphaPixelComponent(q);
+ if (q->opacity != OpaqueOpacity)
+ found_transparent_pixel = MagickTrue;
p+=2;
+ q++;
+ }
+
+#else /* MAGICKCORE_QUANTUM_DEPTH == 8 */
+ *r++=(*p++);
+ p++; /* strip low byte */
+ if (ping_color_type == 4)
+ {
+ q->opacity=(Quantum) (QuantumRange-(*p++));
if (q->opacity != OpaqueOpacity)
found_transparent_pixel = MagickTrue;
+ p++;
q++;
}
+#endif
#endif
}
default:
break;
}
-
/*
Transfer image scanline.
*/
ThrowReaderException(CorruptImageError,"CorruptImage");
}
-#if 0 /* This is probably redundant now */
if (LocaleCompare(image_info->magick,"PNG8") == 0)
{
(void) SetImageType(image,PaletteType);
/* To do: Reduce to binary transparency */
}
}
-#endif
if (LocaleCompare(image_info->magick,"PNG24") == 0)
{
magn_methx=mng_info->magn_methx;
magn_methy=mng_info->magn_methy;
-#if (MAGICKCORE_QUANTUM_DEPTH > 16)
+#if (MAGICKCORE_QUANTUM_DEPTH == 32)
#define QM unsigned short
if (magn_methx != 1 || magn_methy != 1)
{
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
-#if (MAGICKCORE_QUANTUM_DEPTH > 16)
+#if (MAGICKCORE_QUANTUM_DEPTH == 32)
if (magn_methx != 1 || magn_methy != 1)
{
/*
image->depth=16;
#endif
-#if (MAGICKCORE_QUANTUM_DEPTH > 8)
+#if (MAGICKCORE_QUANTUM_DEPTH >= 16)
if (LosslessReduceDepthOK(image) != MagickFalse)
image->depth = 8;
#endif
}
#endif
-#if 0 /* To do: respect the -depth option */
+#if 0 /* To do: honor -depth */
if (image->depth < MAGICKCORE_QUANTUM_DEPTH)
{
}
image->depth=16;
#endif
-#if (MAGICKCORE_QUANTUM_DEPTH > 8)
+#if (MAGICKCORE_QUANTUM_DEPTH >= 16)
if (image->depth == 16 && mng_info->write_png_depth != 16)
if (mng_info->write_png8 || LosslessReduceDepthOK(image) != MagickFalse)
image->depth = 8;
* we need to check for bogus non-opaque values, at least.
*/
+# define PNGK (MAGICKCORE_QUANTUM_DEPTH-8) /* Shift */
+# define PNGM (ScaleCharToQuantum((unsigned char) 0x01)) /* Scale */
+
ExceptionInfo
*exception;
" 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 */
{
if (AcquireImageColormap(image,image_colors) ==
MagickFalse)
- ThrowWriterException(ResourceLimitError,
- "MemoryAllocationFailed");
+ ThrowWriterException(ResourceLimitError, "MemoryAllocationFailed");
for (i=0; i< (ssize_t) image_colors; i++)
image->colormap[i] = colormap[i];
tried_444 = MagickTrue;
image->background_color.red=
- ScaleCharToQuantum(
- (ScaleQuantumToChar(image->background_color.red) & 0xf0) |
- (ScaleQuantumToChar(image->background_color.red) & 0xf0) >> 4);
+ ((((((size_t)
+ image->background_color.red) >> PNGK) & 0xf0) ) |
+ (((((size_t)
+ image->background_color.red) >> PNGK) & 0xf0) >> 4)) * PNGM;
image->background_color.green=
- ScaleCharToQuantum(
- (ScaleQuantumToChar(image->background_color.green) & 0xf0) |
- (ScaleQuantumToChar(image->background_color.green) & 0xf0) >> 4);
+ ((((((size_t)
+ image->background_color.green) >> PNGK) & 0xf0) ) |
+ (((((size_t)
+ image->background_color.green) >> PNGK) & 0xf0) >> 4)) * PNGM;
image->background_color.blue=
- ScaleCharToQuantum(
- (ScaleQuantumToChar(image->background_color.blue) & 0xf0) |
- (ScaleQuantumToChar(image->background_color.blue) & 0xf0) >> 4);
+ ((((((size_t)
+ image->background_color.blue) >> PNGK) & 0xf0) ) |
+ (((((size_t)
+ image->background_color.blue) >> PNGK) & 0xf0) >> 4)) * PNGM;
if (logging != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
}
else
{
- r->red=ScaleCharToQuantum(
- (ScaleQuantumToChar(r->red) & 0xf0) |
- (ScaleQuantumToChar(r->red) & 0xf0) >> 4);
- r->green=ScaleCharToQuantum(
- (ScaleQuantumToChar(r->green) & 0xf0) |
- (ScaleQuantumToChar(r->green) & 0xf0) >> 4);
- r->blue=ScaleCharToQuantum(
- (ScaleQuantumToChar(r->blue) & 0xf0) |
- (ScaleQuantumToChar(r->blue) & 0xf0) >> 4);
+ r->red=
+ ((((((size_t) r->red) >> PNGK) & 0xf0) ) |
+ (((((size_t) r->red) >> PNGK) & 0xf0) >> 4)) * PNGM;
+ r->green=
+ ((((((size_t) r->green) >> PNGK) & 0xf0) ) |
+ (((((size_t) r->green) >> PNGK) & 0xf0) >> 4)) * PNGM;
+ r->blue=
+ ((((((size_t) r->blue) >> PNGK) & 0xf0) ) |
+ (((((size_t) r->blue) >> PNGK) & 0xf0) >> 4)) * PNGM;
}
r++;
}
" Quantizing the colormap to 4-4-4");
for (i=0; i<image_colors; i++)
{
- image->colormap[i].red=ScaleCharToQuantum(
- (ScaleQuantumToChar(image->colormap[i].red) & 0xf0) |
- (ScaleQuantumToChar(image->colormap[i].red) & 0xf0) >> 4);
- image->colormap[i].green=ScaleCharToQuantum(
- (ScaleQuantumToChar(image->colormap[i].green) & 0xf0) |
- (ScaleQuantumToChar(image->colormap[i].green) & 0xf0) >> 4);
- image->colormap[i].blue=ScaleCharToQuantum(
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xf0) |
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xf0 >> 4));
+ image->colormap[i].red=
+ ((((((size_t)
+ image->colormap[i].red) >> PNGK) & 0xf0) ) |
+ (((((size_t)
+ image->colormap[i].red) >> PNGK) & 0xf0) >> 4)) * PNGM;
+ image->colormap[i].green=
+ ((((((size_t)
+ image->colormap[i].green) >> PNGK) & 0xf0) ) |
+ (((((size_t)
+ image->colormap[i].green) >> PNGK) & 0xf0) >> 4)) * PNGM;
+ image->colormap[i].blue=
+ ((((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xf0) ) |
+ (((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xf0) >> 4)) * PNGM;
}
}
continue;
tried_333 = MagickTrue;
image->background_color.red=
- ScaleCharToQuantum(
- (ScaleQuantumToChar(image->background_color.red) & 0xe0) |
- (ScaleQuantumToChar(image->background_color.red) & 0xe0) >> 3 |
- (ScaleQuantumToChar(image->background_color.red) & 0xc0) >> 6);
+ ((((((size_t)
+ image->background_color.red) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->background_color.red) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->background_color.red) >> PNGK) & 0xc0) >> 6)) * PNGM;
image->background_color.green=
- ScaleCharToQuantum(
- (ScaleQuantumToChar(image->background_color.green) & 0xe0) |
- (ScaleQuantumToChar(image->background_color.green) & 0xe0) >> 3 |
- (ScaleQuantumToChar(image->background_color.green) & 0xc0) >> 6);
+ ((((((size_t)
+ image->background_color.green) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->background_color.green) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->background_color.green) >> PNGK) & 0xc0) >> 6)) * PNGM;
image->background_color.blue=
- ScaleCharToQuantum(
- (ScaleQuantumToChar(image->background_color.blue) & 0xe0) |
- (ScaleQuantumToChar(image->background_color.blue) & 0xe0) >> 3 |
- (ScaleQuantumToChar(image->background_color.blue) & 0xc0) >> 6);
+ ((((((size_t)
+ image->background_color.blue) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->background_color.blue) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->background_color.blue) >> PNGK) & 0xc0) >> 6)) * PNGM;
if (logging != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
}
else
{
- r->red=ScaleCharToQuantum(
- (ScaleQuantumToChar(r->red) & 0xe0) |
- (ScaleQuantumToChar(r->red) & 0xe0) >> 3 |
- (ScaleQuantumToChar(r->red) & 0xc0) >> 6);
- r->green=ScaleCharToQuantum(
- (ScaleQuantumToChar(r->green) & 0xe0) |
- (ScaleQuantumToChar(r->green) & 0xe0) >> 3 |
- (ScaleQuantumToChar(r->green) & 0xc0) >> 6);
- r->blue=ScaleCharToQuantum(
- (ScaleQuantumToChar(r->blue) & 0xe0) |
- (ScaleQuantumToChar(r->blue) & 0xe0) >> 3 |
- (ScaleQuantumToChar(r->blue) & 0xc0) >> 6);
+ r->red=
+ ((((((size_t) r->red) >> PNGK) & 0xe0) ) |
+ (((((size_t) r->red) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t) r->red) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ r->green=
+ ((((((size_t) r->green) >> PNGK) & 0xe0) ) |
+ (((((size_t) r->green) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t) r->green) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ r->blue=
+ ((((((size_t) r->blue) >> PNGK) & 0xe0) ) |
+ (((((size_t) r->blue) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t) r->blue) >> PNGK) & 0xc0) >> 6)) * PNGM;
}
r++;
}
" Quantizing the colormap to 3-3-3-1");
for (i=0; i<image_colors; i++)
{
- image->colormap[i].red=ScaleCharToQuantum(
- (ScaleQuantumToChar(image->colormap[i].red) & 0xe0) |
- (ScaleQuantumToChar(image->colormap[i].red) & 0xe0) >> 3 |
- (ScaleQuantumToChar(image->colormap[i].red) & 0xc0) >> 6);
- image->colormap[i].green=ScaleCharToQuantum(
- (ScaleQuantumToChar(image->colormap[i].green) & 0xe0) |
- (ScaleQuantumToChar(image->colormap[i].green) & 0xe0) >> 3 |
- (ScaleQuantumToChar(image->colormap[i].green) & 0xc0) >> 6);
- image->colormap[i].blue=ScaleCharToQuantum(
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xe0) |
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xe0) >> 3 |
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xc0) >> 6);
+ image->colormap[i].red=
+ ((((((size_t)
+ image->colormap[i].red) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->colormap[i].red) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->colormap[i].red) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ image->colormap[i].green=
+ ((((((size_t)
+ image->colormap[i].green) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->colormap[i].green) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->colormap[i].green) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ image->colormap[i].blue=
+ ((((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xc0) >> 6)) * PNGM;
}
}
continue;
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Quantizing the background color to 3-3-2");
- /* Red and green were already done so we only quantize the blue
- * channel
- */
-
- image->background_color.blue=ScaleCharToQuantum(
- (ScaleQuantumToChar(image->background_color.blue) & 0xc0) |
- (ScaleQuantumToChar(image->background_color.blue) & 0xc0) >> 2 |
- (ScaleQuantumToChar(image->background_color.blue) & 0xc0) >> 4 |
- (ScaleQuantumToChar(image->background_color.blue) & 0xc0) >> 6);
+ image->background_color.red=
+ ((((((size_t)
+ image->background_color.red) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->background_color.red) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->background_color.red) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ image->background_color.green=
+ ((((((size_t)
+ image->background_color.green) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->background_color.green) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->background_color.green) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ image->background_color.blue=
+ ((((((size_t)
+ image->background_color.blue) >> PNGK) & 0xc0) ) |
+ (((((size_t)
+ image->background_color.blue) >> PNGK) & 0xc0) >> 2) |
+ (((((size_t)
+ image->background_color.blue) >> PNGK) & 0xc0) >> 4) |
+ (((((size_t)
+ image->background_color.blue) >> PNGK) & 0xc0) >> 6)) * PNGM;
if (logging != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
}
else
{
- r->blue=ScaleCharToQuantum(
- (ScaleQuantumToChar(r->blue) & 0xc0) |
- (ScaleQuantumToChar(r->blue) & 0xc0) >> 2 |
- (ScaleQuantumToChar(r->blue) & 0xc0) >> 4 |
- (ScaleQuantumToChar(r->blue) & 0xc0) >> 6);
+ r->red=
+ ((((((size_t) r->red) >> PNGK) & 0xe0) ) |
+ (((((size_t) r->red) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t) r->red) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ r->green=
+ ((((((size_t) r->green) >> PNGK) & 0xe0) ) |
+ (((((size_t) r->green) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t) r->green) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ r->blue=
+ ((((((size_t) r->blue) >> PNGK) & 0xc0) ) |
+ (((((size_t) r->blue) >> PNGK) & 0xc0) >> 2) |
+ (((((size_t) r->blue) >> PNGK) & 0xc0) >> 4) |
+ (((((size_t) r->blue) >> PNGK) & 0xc0) >> 6)) * PNGM;
}
r++;
}
" Quantizing the colormap to 3-3-2-1");
for (i=0; i<image_colors; i++)
{
- image->colormap[i].blue=ScaleCharToQuantum(
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xc0) |
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xc0) >> 2 |
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xc0) >> 4 |
- (ScaleQuantumToChar(image->colormap[i].blue) & 0xc0) >> 6);
+ image->colormap[i].red=
+ ((((((size_t)
+ image->colormap[i].red) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->colormap[i].red) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->colormap[i].red) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ image->colormap[i].green=
+ ((((((size_t)
+ image->colormap[i].green) >> PNGK) & 0xe0) ) |
+ (((((size_t)
+ image->colormap[i].green) >> PNGK) & 0xe0) >> 3) |
+ (((((size_t)
+ image->colormap[i].green) >> PNGK) & 0xc0) >> 6)) * PNGM;
+ image->colormap[i].blue=
+ ((((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xc0) ) |
+ (((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xc0) >> 2) |
+ (((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xc0) >> 4) |
+ (((((size_t)
+ image->colormap[i].blue) >> PNGK) & 0xc0) >> 6)) * PNGM;
}
}
continue;