On Wed, Jul 28, 2010 at 7:55 AM, Carsten Haitzler <ras...@rasterman.com> wrote:
> On Wed, 14 Jul 2010 18:22:24 +0800 Brian Wang <brian.wang.0...@gmail.com> 
> said:
>
> unfortunately this breaks loading of images from a bmp test suite i have. (as
> such evas's loader loads more files correctly than gqview can). images that
> break are attached.

I have tested the broken image.  I guess you mean they're "invisible"
with my patch?
GIMP can load them correctly.  I briefly browsed GIMP's bmp plug-in
code but could not find how it determines the correct alpha mask for
32-bit BMP.  I could not find relevant specification about ARGB 32-bit
BMP in BMP v3 specification.  Without proper reference, I can only
come up with a workaround...  Any BMP wizards here?

However, I think the attached patch does the trick.  It first sets
hasa flag and if all pixels are transparent (I guess it's an
uninteresting/useless image if the user can't see any pixel of it), it
set the Image_Entry's alpha flag to zero.

g32def.bmp, g32bf.bmp and the attached Icon.bmp can all be loaded
properly.  Any more interesting BMPs?  :-)

Thanks for looking into this.


brian

>
>> Hello all,
>>
>> GIMP (2.6.8) seems to save 32-bit BMP in the "Windows 3.0 + (v3)"
>> format mentioned in evas_image_load_bmp.c.
>> I'm not sure if the patch breaks anything (or images created by other
>> tools).  Please correct it if you see fit.
>> This patch should enable support for ARGB BMP files for evas.  It's
>> tested on my x86 box.
>>
>> Cheers,
>>
>>
>> brian
>>
>> --
>> brian
>> ------------------
>>
>> Cool-Karaoke - The smallest recording studio, in your palm, open-sourced
>> http://cool-idea.com.tw/
>>
>> iMaGiNaTiOn iS mOrE iMpOrTaNt tHaN kNoWlEdGe
>
>
> --
> ------------- Codito, ergo sum - "I code, therefore I am" --------------
> The Rasterman (Carsten Haitzler)    ras...@rasterman.com
>
>



-- 
brian
------------------

Cool-Karaoke - The smallest recording studio, in your palm, open-sourced
http://cool-idea.com.tw/

iMaGiNaTiOn iS mOrE iMpOrTaNt tHaN kNoWlEdGe
Index: evas/src/modules/loaders/bmp/evas_image_load_bmp.c
===================================================================
--- evas/src/modules/loaders/bmp/evas_image_load_bmp.c  (revision 50528)
+++ evas/src/modules/loaders/bmp/evas_image_load_bmp.c  (working copy)
@@ -148,6 +148,7 @@
         if (!read_int(f, &tmp2)) goto close_file;
         important_colors = tmp2; // number of important colors - 0 if all
         if (image_size == 0) image_size = fsize - offset;
+        if ((comp == 0) && (bit_count == 32)) hasa = 1; // GIMP seems to store 
it this way
      }
    else if (head_size == 108) // Windows 95/NT4 + (v4)
      {
@@ -423,6 +424,7 @@
         if (!read_int(f, &tmp2)) goto close_file;
         important_colors = tmp2; // number of important colors - 0 if all
         if (image_size == 0) image_size = fsize - offset;
+        if ((comp == 0) && (bit_count == 32)) hasa = 1; // GIMP seems to store 
it this way
      }
    else if (head_size == 108) // Windows 95/NT4 + (v4)
      {
@@ -933,6 +935,7 @@
                }
              else if (bit_count == 32)
                {
+                  int none_zero_alpha = 0;
                   pix = surface;
                   for (y = 0; y < h; y++)
                     {
@@ -943,6 +946,7 @@
                             g = p[1];
                             r = p[2];
                             a = p[3];
+                            if (a) none_zero_alpha = 1;
                             if (!hasa) a = 0xff;
                             *pix = ARGB_JOIN(a, r, g, b);
                             p += 4;
@@ -953,6 +957,7 @@
                        if (fix > 0) p += 4 - fix; // align row read
                        if (p >= buffer_end) break;
                     }
+                    if (!none_zero_alpha) ie->flags.alpha = 0;
                }
              else
                goto close_file;

<<attachment: Icon.bmp>>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to