Patiencer / thtmlviewer

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

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

Closed GoogleCodeExporter closed 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

GoogleCodeExporter commented 9 years ago
commit 
https://github.com/BerndGabriel/HtmlViewer/commit/bc29d9765e9be01bf4e7b17cfb3412
2e3b404011 fixes this issue.

Original comment by OrphanCat on 17 Jun 2015 at 8:36