ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 8 bits png with transparent color
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

nwscomps

185 Posts

Posted - Mar 01 2012 :  17:30:21  Show Profile  Reply
I know that I can save a 32bits png but it would be nice to have the transparent color support for 8 bits png like it is for Gif. Will it be implemented? Thank you.

Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library

nwscomps

185 Posts

Posted - Mar 03 2012 :  11:36:29  Show Profile  Reply
Sorry did I ask something too hard to answer? I hope to get a response :)

Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library
Go to Top of Page

fab

1310 Posts

Posted - Mar 03 2012 :  14:53:36  Show Profile  Reply
Hi Francesco, sorry for the delay.
In order to save a PNG with 8 bits per pixel (with palette) and alpha channel you have to set BitsPerSample=8 and SamplesPerPixel=1, for example:

ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 1;
ImageEnView1.IO.SaveToFile('output.png');

Please note that previous versions (< 4.1) cannot load alpha channel from 8bpp PNGs, while saving is supported.
Go to Top of Page

nwscomps

185 Posts

Posted - Mar 04 2012 :  12:17:23  Show Profile  Reply
Hi Fabrizio, thanks for your answer, this will save a 8bits png with alpha channel (which is a good alternative) but I was looking for the equivalent of Gif's transparent color. In gif you can set a color to be transparent so that you can simulate the effect of a transparent background. Is there any way to do that with png?

Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library
Go to Top of Page

fab

1310 Posts

Posted - Mar 04 2012 :  12:45:51  Show Profile  Reply
You can modify the alpha channel so that a color (or a range of colors) becomes transparent using SetTransparentColors. For example this will make all colors from 0,0,0 (black) up to 128,128,128 (gray) transparent:

ImageEnView1.Proc.SetTransparentColors(CreateRGB(0,0,0), CreateRGB(100,100,100), 0);
ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 1;
ImageEnView1.IO.SaveToFile('test.png');

A field like GIF_TranspColor is not currently planned for PNG.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: