hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=f5aa672853d4fe70a60508e9abc796b0246915ba

commit f5aa672853d4fe70a60508e9abc796b0246915ba
Author: Shinwoo Kim <cinoo....@samsung.com>
Date:   Fri Aug 16 16:54:50 2019 +0900

    evas: fix png regression issue
    
    Summary:
    The evas_image_load_file_data_png had called png_set_tRNS_to_alpha
    from following commit.
    
       6988a38 evas: fix png loader to actually produce lower resolution
               content when asked.
    
    You could refer to following information regarding png_set_tRNS_to_alpha
    which is available on page http://www.libpng.org/pub/png/libpng-manual.txt
    
       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.  This is most useful on
       grayscale images with bit depths of 2 or 4 or if there is a 
multiple-image
       viewing application that wishes to treat all images in the same way.
    
           if (color_type == PNG_COLOR_TYPE_PALETTE)
               png_set_palette_to_rgb(png_ptr);
    
           if (png_get_valid(png_ptr, info_ptr,
               PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
    
           if (color_type == PNG_COLOR_TYPE_GRAY &&
               bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr)
    
    Accidentally commit "382c580 evas: add support for .9.png file to PNG 
loader."
    adding a new feature with small code refactoring missed the line calling
    png_set_tRNS_to_alpha.
    
    So we got a rendering issue. It made around 75% size white rectangle
    using a grayscale and transparent image. I'd like to attach the image
    which has following type information for test purpose.
    
    $ identify -verbose ./grayscale_transparent.png | grep type -i
      Mime type: image/png
      Type: Bilevel
        png:IHDR.color-type-orig: 0
        png:IHDR.color_type: 0 (Grayscale)
    
    Test Plan:
    This is the sample image file grayscale_transparent.png
    
    {F3748665}
    
    Reviewers: cedric, Hermet, jsuya
    
    Reviewed By: Hermet
    
    Subscribers: #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D9580
---
 src/modules/evas/image_loaders/png/evas_image_load_png.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/modules/evas/image_loaders/png/evas_image_load_png.c 
b/src/modules/evas/image_loaders/png/evas_image_load_png.c
index 7b440d5089..1eb8b12dc8 100644
--- a/src/modules/evas/image_loaders/png/evas_image_load_png.c
+++ b/src/modules/evas/image_loaders/png/evas_image_load_png.c
@@ -212,7 +212,14 @@ 
_evas_image_load_file_internal_head_png(Evas_Loader_Internal *loader,
         prop->info.w = (int) epi->w32;
         prop->info.h = (int) epi->h32;
      }
-   if (png_get_valid(epi->png_ptr, epi->info_ptr, PNG_INFO_tRNS)) epi->hasa = 
1;
+
+   if (png_get_valid(epi->png_ptr, epi->info_ptr, PNG_INFO_tRNS))
+     {
+        /* expand transparency entry -> alpha channel if present */
+        if (!close_file) png_set_tRNS_to_alpha(epi->png_ptr);
+        epi->hasa = 1;
+     }
+
    switch (epi->color_type)
      {
       case PNG_COLOR_TYPE_RGB_ALPHA:

-- 


Reply via email to