Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-04

TImage and PNG (on linux)

14 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leonardo M. Ramé

Hi, I was testing a sample project and found that on Windows, handling of PNGs with transparent backgrounds is working ok, but on Linux it doesn't work as expected. The image is a black line on the top of the image, with a Gaussian Blur applied on Photoshop, then saved to PNG with transparent background.

I attached an image showing what I get on Windows vs Linux, also the original image.

Thanks in advance,

Leonardo M. Ram? http://leonardorame.blogspot.com -------------- next part -------------- A non-text attachment was scrubbed... Name: png_transparent.jpg Type: image/jpeg Size: 9070 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110410/571063fa/attachment.jpg> -------------- next part -------------- A non-text attachment was scrubbed... Name: sombra_top_horiz.png Type: image/png Size: 209 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110410/571063fa/attachment.png>

Reply by email

Leonardo M. Ramé
to Leonardo M. Ramé
Leonardo M. Ram? wrote 9 lines
On 2011-04-10 22:45:22 +0200, Felipe Monteiro de Carvalho wrote: > No test source code? > > -- > Felipe Monteiro de Carvalho Just place a TImage on a form, then load the attached png (sombra_bottom_horiz.png) into it.

Here it is anyway.

Leonardo M. Ram? http://leonardorame.blogspot.com -------------- next part -------------- A non-text attachment was scrubbed... Name: test.7z Type: application/octet-stream Size: 60263 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110410/0f3f84ca/attachment-0001.obj>

Reply by email

silvioprog
to Leonardo M. Ramé

2011/4/10 Leonardo M. Ram? :

Show quoted text 16 lines
On 2011-04-10 17:49:03 -0300, Leonardo M. Ram? wrote: > On 2011-04-10 22:45:22 +0200, Felipe Monteiro de Carvalho wrote: > > No test source code? > > > > -- > > Felipe Monteiro de Carvalho > > Just place a TImage on a form, then load the attached png > (sombra_bottom_horiz.png) into it. > Here it is anyway. -- Leonardo M. Ram? http://leonardorame.blogspot.com

This error appears to me too: :(

[TImage] http://imagebin.org/147499
[TrayIcon] http://imagebin.org/147500 (normal transparency only in Windows >:(~ ).

Test in attached.

Lazarus 0.9.31 r30018M FPC 2.5.1 i386-linux-gtk 2

Silvio Cl?cio ============================================= Blog - silvioprog.com.br Twitter - twitter.com/silvioprog LazSolutions - code.google.com/p/lazsolutions Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR ============================================= -------------- next part -------------- A non-text attachment was scrubbed... Name: test.zip Type: application/zip Size: 2787 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110410/617754a1/attachment.zip>

Reply by email

Marco van de Voort
to Leonardo M. Ramé: Hi, I was testing a sample project and found that on Windows, handling of PNGs with…
Leonardo M. Ram? wrote 8 lines
Hi, I was testing a sample project and found that on Windows, handling of PNGs with transparent backgrounds is working ok, but on Linux it doesn't work as expected. The image is a black line on the top of the image, with a Gaussian Blur applied on Photoshop, then saved to PNG with transparent background. I attached an image showing what I get on Windows vs Linux, also the original image.

Afaik there is already a report for this in mantis.

Reply by email

Marc Weustink
to Leonardo M. Ramé: Hi, I was testing a sample project and found that on Windows, handling of PNGs with…
Leonardo M. Ram? wrote 8 lines
Hi, I was testing a sample project and found that on Windows, handling of PNGs with transparent backgrounds is working ok, but on Linux it doesn't work as expected. The image is a black line on the top of the image, with a Gaussian Blur applied on Photoshop, then saved to PNG with transparent background. I attached an image showing what I get on Windows vs Linux, also the original image.

The current linux-gtk implementation has only a 1 bit alpha

Marc

Reply by email

Krzysztof
to Leonardo M. Ramé: Hi, I was testing a sample project and found that on Windows, handling of PNGs with…

This is known issue. GTK have no alpha yet but I created set of components which partially solve this problem by using BGRABitmap class, details: http://www.lazarus.freepascal.org/index.php/topic,12411.0.html . Although there is no TImage yet but I can try create it.
For TrayIcon on GTK you must rebuild lazarus with -dUseStatusIcon switch. If tray still have no alpha then you must add this 3 lines posted by TrUsTeR: http://www.lazarus.freepascal.org/index.php/topic,6583.0.html After this tray icon works perfect in my case.

2011/4/10 Leonardo M. Ram?

Show quoted text 21 lines
Hi, I was testing a sample project and found that on Windows, handling of PNGs with transparent backgrounds is working ok, but on Linux it doesn't work as expected. The image is a black line on the top of the image, with a Gaussian Blur applied on Photoshop, then saved to PNG with transparent background. I attached an image showing what I get on Windows vs Linux, also the original image. Thanks in advance, -- Leonardo M. Ram? http://leonardorame.blogspot.com -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110412/c4e82a43/attachment-0001.html>

Reply by email

Leonardo M. Ramé
to Krzysztof
Krzysztof wrote 35 lines
This is known issue. GTK have no alpha yet but I created set of components which partially solve this problem by using BGRABitmap class, details: http://www.lazarus.freepascal.org/index.php/topic,12411.0.html . Although there is no TImage yet but I can try create it. For TrayIcon on GTK you must rebuild lazarus with -dUseStatusIcon switch. If tray still have no alpha then you must add this 3 lines posted by TrUsTeR: http://www.lazarus.freepascal.org/index.php/topic,6583.0.html After this tray icon works perfect in my case. 2011/4/10 Leonardo M. Rame Hi, I was testing a sample project and found that on Windows, handling of PNGs with transparent backgrounds is working ok, but on Linux it doesn't work as expected. The image is a black line on the top of the image, with a Gaussian Blur applied on Photoshop, then saved to PNG with transparent background. I attached an image showing what I get on Windows vs Linux, also the original image. Thanks in advance, -- Leonardo M. Rame http://leonardorame.blogspot.com -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Well, I don't really need TImage, but TPicture. What I need is to be able to use TCanvas methods to copy this picture into another TCanvas.

Does your component allows this?

Reply by email

Krzysztof
to Leonardo M. Ramé

So if you want operate on bitmaps and canvas then maybe it is better to read about BGRABitmap and do this same things which i'm doing in my components. This is very interesting class. You can load PNG image to this class and draw wherever you want similar like with canvas (but with alpha). Details: http://wiki.lazarus.freepascal.org/BGRABitmap
and few tutorials (with nice effects):
http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial This is crossplatform library

2011/4/12 Leonardo M. Ram?

Show quoted text 60 lines
On 2011-04-12 19:22:36 +0200, Krzysztof wrote: > This is known issue. GTK have no alpha yet but I created set of components > which partially solve this problem by using BGRABitmap class, details: > http://www.lazarus.freepascal.org/index.php/topic,12411.0.html . Although > there is no TImage yet but I can try create it. > For TrayIcon on GTK you must rebuild lazarus with -dUseStatusIcon switch. > If tray still have no alpha then you must add this 3 lines posted by > TrUsTeR: > http://www.lazarus.freepascal.org/index.php/topic,6583.0.html > After this tray icon works perfect in my case. > 2011/4/10 Leonardo M. Rame > > Hi, I was testing a sample project and found that on Windows, handling > of PNGs with transparent backgrounds is working ok, but on Linux it > doesn't work as expected. The image is a black line on the top of the > image, with a Gaussian Blur applied on Photoshop, then saved to PNG with > transparent background. > > I attached an image showing what I get on Windows vs Linux, also the > original image. > > Thanks in advance, > -- > Leonardo M. Rame > http://leonardorame.blogspot.com > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus Well, I don't really need TImage, but TPicture. What I need is to be able to use TCanvas methods to copy this picture into another TCanvas. Does your component allows this? -- Leonardo M. Ram? http://leonardorame.blogspot.com -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110412/792d54a7/attachment.html>

Reply by email

Leonardo M. Ramé
to Krzysztof
Krzysztof wrote 10 lines
So if you want operate on bitmaps and canvas then maybe it is better to read about BGRABitmap and do this same things which i'm doing in my components. This is very interesting class. You can load PNG image to this class and draw wherever you want similar like with canvas (but with alpha). Details: http://wiki.lazarus.freepascal.org/BGRABitmap and few tutorials (with nice effects): http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial This is crossplatform library

You are right Krzysztof, in fact, I adapted my code to BGRABitmap and it worked like a charm.

Just a note. I miss the LoadFromLazResource method, like TPicture. Do you plan to add this feature?.

Reply by email

Krzysztof
to Leonardo M. Ramé

I am not the author of BGRABitmap class but I think it is easy to assign bitmap from resource to BGRABitmap class. You can load image from resource using TResourceStream (there is tutorial on wiki) and then call BGRABitmap.LoadFromStream(MyResourceStream)

2011/4/12 Leonardo M. Ram?

Show quoted text 31 lines
On 2011-04-12 20:18:48 +0200, Krzysztof wrote: > So if you want operate on bitmaps and canvas then maybe it is better to > read about BGRABitmap and do this same things which i'm doing in my > components. This is very interesting class. You can load PNG image to this > class and draw wherever you want similar like with canvas (but with > alpha). Details: > http://wiki.lazarus.freepascal.org/BGRABitmap > and few tutorials (with nice effects): > http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial > This is crossplatform library > You are right Krzysztof, in fact, I adapted my code to BGRABitmap and it worked like a charm. Just a note. I miss the LoadFromLazResource method, like TPicture. Do you plan to add this feature?. -- Leonardo M. Ram? http://leonardorame.blogspot.com -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110412/9d15b768/attachment.html>

Reply by email

Leonardo M. Ramé
to Krzysztof
Krzysztof wrote
I am not the author of BGRABitmap class but I think it is easy to assign bitmap from resource to BGRABitmap class. You can load image from resource using TResourceStream (there is tutorial on wiki) and then call BGRABitmap.LoadFromStream(MyResourceStream)

I tried this and got an 'ExceptionException Unknown/Unsupported PCX image type'. The resource contains a PNG image.

  lRes := TLazarusResourceStream.Create('sombra_top_horiz', 'PNG');
  try
    lRes.Position:= 0;
    FMyTBGRABitmap.LoadFromStream(lRes);
  finally
    lRes.Free;
  end;

Any workaround?

Leonardo M. Ram? http://leonardorame.blogspot.com A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?

Reply by email

Leonardo M. Ramé
to Leonardo M. Ramé
Leonardo M. Ram? wrote 18 lines
On 2011-04-12 20:36:34 +0200, Krzysztof wrote: > I am not the author of BGRABitmap class but I think it is easy to assign > bitmap from resource to BGRABitmap class. You can load image from resource > using TResourceStream (there is tutorial on wiki) and then call > BGRABitmap.LoadFromStream(MyResourceStream) I tried this and got an 'ExceptionException Unknown/Unsupported PCX image type'. The resource contains a PNG image. lRes := TLazarusResourceStream.Create('sombra_top_horiz', 'PNG'); try lRes.Position:= 0; FMyTBGRABitmap.LoadFromStream(lRes); finally lRes.Free; end; Any workaround?

I found a solution. To load the stream with a TFPReader, here's the code, for the record:

var
  lResTop: TLazarusResourceStream;
  lPngReader: TFPReaderPNG;
begin
  inherited Create(TheOwner);
  FShadowTop := TBGRABitmap.Create;
  FShadowBottom := TBGRABitmap.Create;
  lPngReader := TFPReaderPNG.create;
  lResTop := TLazarusResourceStream.Create('sombra_top_horiz', 'PNG');
  try
    lResTop.Position:= 0;
    FShadowTop.LoadFromStream(lResTop, lPngReader);
  finally
    lResTop.Free;
    lPngReader.Free;
  end;

Reply by email