Re: Creating PNG file with transparency
"Nguyen Vu Hung" <[email protected]> Thu, 9 Oct 2008 11:44:43 +0900
| Newsgroups | gmane.comp.video.graphicsmagick.core |
|---|---|
| Message-ID | <[email protected]> |
Hello, 2008/10/9 Bob Friesenhahn <[email protected]> > > While most graphics programs use an alpha channel which represents the > degree of transparency, GraphicsMagich has an opacity channel which > represents the degree of opacity (inverse of transparency). An opaque image > has an opacity value of 0 and a completely transparent pixel has an opacity > value of MaxRGB. In the "0, 0, 0,255", the 255 indicates completely > transparent. Similarly, the "FF" is max range in the color specification > and indicates completely transparent. > > PNG and GIF have the ability to assign a single color as being the > "transparent". This requires a colormapped image representation. > GraphicsMagick has a special "PNG8" output option to support this binary > transparency. > Thanks for your explanation. > > > A sample code would be nice if you are kind enough. >> > > While I will not write the entire program for you, causing an image color > to be transparent is quite easy to do via the 'transparent' method of the > Image class. For example > > image.transparent("white"); Is this equivalent to image.matteColor("white"); // ? > > will set any white color in the image to transparent. You can explicity > write PNG8 format like > > image.write("PNG8:output.png"). I write: image.magick("PNG8"); image.write("output.png"); Are they the same? > > You can also create a transparent white canvas image and draw or composite > on top of it, but this may obtain full alpha transparency rather than simple > binary transparency. > > Do you mean something like: Image image( "400x400", "white" ); // write some pixels with // image.pixelColor image.write( "output.png" ); -- Best Regards, Nguyen Hung Vu ( Nguyễn Vũ Hưng ) vuhung16plus{remove}@gmail.dot.com <vuhung16plus%7Bremove%[email protected]>, YIM: vuhung16 , Skype: vuhung16dg A brief profile: http://www.hn.is.uec.ac.jp/~vuhung/Nguyen.Vu.Hung.html ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Graphicsmagick-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/graphicsmagick-core