kooloveme / thtmlviewer

Automatically exported from code.google.com/p/thtmlviewer
Other
0 stars 0 forks source link

transp attribute in <img > tag (lower left corner) doesn't work if GDIPLUS is enabled #387

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Which steps will reproduce the problem?

1. Use a tag like <img src=A.BMP transp>
2. Lower left corner of A.BMP and pixels with the same colore should become 
transparent, but they don't
3. Only if I define NOGDIPLUS then the "transp" attribute works and the pixels 
become transparent

What is the expected output? What do you see instead?

1. The expected output is the the lower left corner of A.BMP and the same 
colored pixels should be transparent, by they aren't.

2. If I use {$define NOGDIPLUS} and recompile, then the transparency works as 
expected.

Which version of the product are you using? Which compiler version are you
using? On which operating system?

11.5 with Delphi 7

Please attach test html files and screenshots, if appropriate.
Please provide any additional information:

I believe the problem is here (HtmlImages.pas, around line 600) :

{$ifndef NoGDIPlus}
    if not (ImageFormat in [itGif]) then
      try
        Result := LoadGpImage;
      except
        // just continue without image...
      end;
{$endif !NoGDIPlus}

I notice that "LoadGpImage" doesn't check for transparency, while the code that 
follows does.

So, to fix it for myself, I changed the line:

    if not (ImageFormat in [itGif]) then

Into:

    if not (ImageFormat in [itGif, itBmp]) then

And in this way, BMP files are not loaded with GDI+ but in the old way, and 
LLCorner transparency is applied as before.

While the above works for me, you may want to take a more comprehensive look at 
the issue, and either implement LLCorner transparency in GDI+, or exclude more 
file types from GDI+ processing, or at least notify the programmers about the 
issue.

Thanks!!

Manlio

Original issue reported on code.google.com by manlio.m...@gmail.com on 26 Nov 2014 at 4:59

GoogleCodeExporter commented 9 years ago
Thanks for spotting this issue.

Original comment by OrphanCat on 30 Dec 2014 at 1:36