pass,
ping_bit_depth,
ping_color_type,
+ ping_file_depth,
ping_interlace_method,
ping_compression_method,
ping_filter_method,
&ping_interlace_method,&ping_compression_method,
&ping_filter_method);
+ ping_file_depth = ping_bit_depth;
+
(void) png_get_tRNS(ping, ping_info, &ping_trans_alpha, &ping_num_trans,
&ping_trans_color);
if (ping_bit_depth < 8)
{
- if (((int) ping_color_type == PNG_COLOR_TYPE_PALETTE))
- {
- png_set_packing(ping);
- ping_bit_depth = 8;
- }
+ png_set_packing(ping);
+ ping_bit_depth = 8;
}
image->depth=ping_bit_depth;
bkgd_scale = 1;
- if (ping_bit_depth == 1)
+ if (ping_file_depth == 1)
bkgd_scale = 255;
- else if (ping_bit_depth == 2)
+ else if (ping_file_depth == 2)
bkgd_scale = 85;
- else if (ping_bit_depth == 4)
+ else if (ping_file_depth == 4)
bkgd_scale = 17;
- if (ping_bit_depth <= 8)
+ if (ping_file_depth <= 8)
bkgd_scale *= 257;
ping_background->red *= bkgd_scale;
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Reading PNG tRNS chunk.");
- max_sample = (int) ((one << ping_bit_depth) - 1);
+ max_sample = (int) ((one << ping_file_depth) - 1);
if ((ping_color_type == PNG_COLOR_TYPE_GRAY &&
(int)ping_trans_color->gray > max_sample) ||
int
scale_to_short;
- scale_to_short = 65535L/((1UL << ping_bit_depth)-1);
+ scale_to_short = 65535L/((1UL << ping_file_depth)-1);
/* Scale transparent_color to short */
transparent_color.red= scale_to_short*ping_trans_color->red;
image->storage_class=PseudoClass;
one=1;
- image->colors=one << ping_bit_depth;
+ image->colors=one << ping_file_depth;
#if (MAGICKCORE_QUANTUM_DEPTH == 8)
if (image->colors > 256)
image->colors=256;
size_t
scale;
- scale=(QuantumRange/((1UL << ping_bit_depth)-1));
+ scale=(QuantumRange/((1UL << ping_file_depth)-1));
if (scale < 1)
scale=1;
char
msg[MaxTextExtent];
- /* encode ping_width, ping_height, ping_bit_depth, ping_color_type,
+ /* encode ping_width, ping_height, ping_file_depth, ping_color_type,
ping_interlace_method in value */
(void) FormatLocaleString(msg,MaxTextExtent,
"%d, %d",(int) ping_width, (int) ping_height);
(void) SetImageProperty(image,"png:IHDR.width,height ",msg,exception);
- (void) FormatLocaleString(msg,MaxTextExtent,"%d",(int) ping_bit_depth);
+ (void) FormatLocaleString(msg,MaxTextExtent,"%d",(int) ping_file_depth);
(void) SetImageProperty(image,"png:IHDR.bit_depth ",msg,exception);
(void) FormatLocaleString(msg,MaxTextExtent,"%d (%s)",
switch (ping_bit_depth)
{
- case 1:
- {
- register ssize_t
- bit;
-
- for (x=(ssize_t) image->columns-7; x > 0; x-=8)
- {
- for (bit=7; bit >= 0; bit--)
- *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++=(Quantum) ((*p) & (0x01 << bit) ? 0x01 : 0x00);
- }
-
- break;
- }
-
- case 2:
- {
- for (x=(ssize_t) image->columns-3; x > 0; x-=4)
- {
- *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++=(Quantum) ((*p >> (i*2)) & 0x03);
- }
-
- break;
- }
-
- case 4:
- {
- for (x=(ssize_t) image->columns-1; x > 0; x-=2)
- {
- *r++=(*p >> 4) & 0x0f;
- *r++=(*p++) & 0x0f;
- }
-
- if ((image->columns % 2) != 0)
- *r++=(*p++ >> 4) & 0x0f;
-
- break;
- }
-
case 8:
{
if (ping_color_type == 4)