- png_init_io(png_ptr, fp);
- png_read_info(png_ptr, info_ptr);
-
- color_type = png_get_color_type(png_ptr, info_ptr);
- bit_depth = png_get_bit_depth(png_ptr, info_ptr);
- width = png_get_image_width (png_ptr, info_ptr);
- height = png_get_image_height(png_ptr, info_ptr);
-
- /* Skip the alpha channel if present
- * stripping alpha currently doesn't work in conjunction with
- * converting to grayscale in libpng */
- pixel_width = color_type & PNG_COLOR_MASK_ALPHA ? 2 : 1;
- /* Convert 16 bit data to 8 bit */
- if( bit_depth == 16 ) png_set_strip_16(png_ptr);
- /* Expand to 1 pixel per byte if necessary */
- if( bit_depth < 8 ) png_set_packing(png_ptr);
-
- /* Convert to grayscale */
- if( color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_RGB_ALPHA )
- png_set_rgb_to_gray_fixed(png_ptr, 1, -1, -1);
-
- /* Allocate memory to hold the original png image */
- image = (png_bytep*)new png_bytep[height];
- for( row=0; row<(int)height; ++row )
- image[row] = new png_byte[width*pixel_width];
-
- /* Allocate memory for the pattern image that will actually be
- * used for the wipe */
- pattern_image = new unsigned char*[frame_height];
-
- png_read_image(png_ptr, image);
- png_read_end(png_ptr, end_info);
-