png_ptr->rowbytes = ((png_ptr->width * (png_uint_32)png_ptr->pixel_depth + 7) >> 3);
png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length){   png_byte buf[13];   png_uint_32 width, height;   int bit_depth, color_type, compression_type, filter_type;   int interlace_type;   png_debug(1, "in png_handle_IHDR\n");   if (png_ptr->mode & PNG_HAVE_IHDR)      png_error(png_ptr, "Out of place IHDR");   /* check the length */   if (length != 13)      png_error(png_ptr, "Invalid IHDR chunk");   png_ptr->mode |= PNG_HAVE_IHDR;   png_crc_read(png_ptr, buf, 13);   png_crc_finish(png_ptr, 0);   width = png_get_uint_32(buf);   height = png_get_uint_32(buf + 4);   bit_depth = buf[8];   color_type = buf[9];   compression_type = buf[10];   filter_type = buf[11];   interlace_type = buf[12];   /* set internal variables */   png_ptr->width = width;   png_ptr->height = height;   png_ptr->bit_depth = (png_byte)bit_depth;   png_ptr->interlaced = (png_byte)interlace_type;   png_ptr->color_type = (png_byte)color_type;#if defined(PNG_MNG_FEATURES_SUPPORTED)   png_ptr->filter_type = (png_byte)filter_type;#endif   /* find number of channels */   switch (png_ptr->color_type)   {      case PNG_COLOR_TYPE_GRAY:      case PNG_COLOR_TYPE_PALETTE:         png_ptr->channels = 1;         break;      case PNG_COLOR_TYPE_RGB:         png_ptr->channels = 3;         break;      case PNG_COLOR_TYPE_GRAY_ALPHA:         png_ptr->channels = 2;         break;      case PNG_COLOR_TYPE_RGB_ALPHA:         png_ptr->channels = 4;         break;   }   /* set up other useful info */   png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *   png_ptr->channels);   png_ptr->rowbytes = ((png_ptr->width *      (png_uint_32)png_ptr->pixel_depth + 7) >> 3);   png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth);   png_debug1(3,"channels = %d\n", png_ptr->channels);   png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes);   png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,      color_type, interlace_type, compression_type, filter_type);}