]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - plugins/imagepng/plugin.cpp
Merge commit '515673c08f8718a237e90c2130a1f5294f966d6a'
[xonotic/netradiant.git] / plugins / imagepng / plugin.cpp
index 3b76144733d96d744995342707942ac3e447f002..9d1a3e358674efbfabe0cb6ac15a9e5c18da4641 100644 (file)
@@ -87,7 +87,7 @@ Image* LoadPNGBuff (unsigned char* fbuffer)
   }
 
   // configure the read function
-  png_set_read_fn(png_ptr, (voidp)&p_fbuffer, (png_rw_ptr)&user_read_data);
+  png_set_read_fn(png_ptr, (png_voidp)&p_fbuffer, (png_rw_ptr)&user_read_data);
 
   if (setjmp(png_jmpbuf(png_ptr))) {
     png_destroy_read_struct(&png_ptr, &info_ptr,
@@ -104,8 +104,11 @@ Image* LoadPNGBuff (unsigned char* fbuffer)
   //   The following code transforms grayscale images of less than 8 to 8 bits, 
   //   changes paletted images to RGB, and adds a full alpha channel if there is 
   //   transparency information in a tRNS chunk.
-  if (color_type == PNG_COLOR_TYPE_PALETTE)
-   png_set_palette_to_rgb(png_ptr);
+
+  if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+    png_set_gray_to_rgb(png_ptr);
+  else if (color_type == PNG_COLOR_TYPE_PALETTE)
+    png_set_palette_to_rgb(png_ptr);
 
   if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
     png_set_expand_gray_1_2_4_to_8(png_ptr);