]> mj.ucw.cz Git - libucw.git/blobdiff - images/io-libpng.c
small bugfixes about transparency
[libucw.git] / images / io-libpng.c
index 1e1704f8cef4547fe1b28766c4c9e5c716838117..fe60fef60437ae765dee89a3821d38da5ca509ec 100644 (file)
@@ -217,6 +217,7 @@ libpng_read_data(struct image_io *io)
   switch (rd->color_type)
     {
       case PNG_COLOR_TYPE_PALETTE:
+       /* FIXME: add support for palette with colors */
        if ((io->flags & IMAGE_COLOR_SPACE) == COLOR_SPACE_GRAYSCALE)
          {
            png_set_palette_to_rgb(rd->png_ptr);
@@ -255,13 +256,11 @@ libpng_read_data(struct image_io *io)
       case PNG_COLOR_TYPE_RGB_ALPHA:
        if ((io->flags & IMAGE_COLOR_SPACE) == COLOR_SPACE_GRAYSCALE)
          png_set_rgb_to_gray_fixed(rd->png_ptr, 1, 21267, 71514);
-       if (!(io->flags & IMAGE_ALPHA) && (io->flags & IMAGE_PIXEL_FORMAT) != (COLOR_SPACE_RGB | IMAGE_PIXELS_ALIGNED))
-         {
-           if (io->flags & IMAGE_IO_USE_BACKGROUND)
-             read_flags |= IMAGE_ALPHA;
-           else
-              png_set_strip_alpha(rd->png_ptr);
-         }
+       if (!(io->flags & IMAGE_ALPHA))
+         if (io->flags & IMAGE_IO_USE_BACKGROUND)
+           read_flags |= IMAGE_ALPHA;
+         else if ((io->flags & IMAGE_PIXEL_FORMAT) != (COLOR_SPACE_RGB | IMAGE_PIXELS_ALIGNED))
+            png_set_strip_alpha(rd->png_ptr);
        break;
       default:
        ASSERT(0);