png_get_IHDR( png_ptr, info_ptr, &width, &height,
&depth, &color_type, NULL, NULL, NULL);
- if (color_type == PNG_COLOR_TYPE_RGBA)
- has_alpha = 1;
- else if (color_type == PNG_COLOR_TYPE_RGB)
- has_alpha = 0;
- else {
- LOGW("unknown color_type");
- goto close_png_ptr;
+ has_alpha = color_type & PNG_COLOR_MASK_ALPHA;
+
+ // If we get gray and alpha only, standardize the format of the pixels.
+ // GA is not supported by OpenGL ES 1.
+ if (!(color_type & PNG_COLOR_MASK_COLOR)) {
+ png_set_gray_to_rgb(png_ptr);
+ png_set_palette_to_rgb(png_ptr);
+ png_read_update_info(png_ptr, info_ptr);
}
LOGW("w: %i, h: %i", width, height);