GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Solved] Read png with transparent color

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
croco



Joined: 04 Jan 2008
Posts: 4

PostPosted: Sun Jan 06, 2008 5:04 pm    Post subject: [Solved] Read png with transparent color Reply with quote

Hi to all!

Conceptual problem: I would like to read in a png and define one RGB value as transparent color (let's say: 0/0/0). No alpha channel involved.

My first idea was to create a transparency bitmap, to read the image as pixbuf, to render it to a pixmap and finally to apply the bitmap as transparency mask. Unfortunatly I didn't find any method to apply a transparency mask to a pixmap afterwards. The only method I could find, was gdk_pixmap_create_from_xpm_d(), dealing with transparency masks in company with a read in from XPM data. But I would be very glad to avoid XPM.

Does anybody has an idea? Thank you very much!

Best regards

Croco


Last edited by croco on Tue Jan 08, 2008 3:26 pm; edited 1 time in total
Back to top
croco



Joined: 04 Jan 2008
Posts: 4

PostPosted: Tue Jan 08, 2008 3:26 pm    Post subject: Reply with quote

Solved:

Some questions had to be answered:

1.) Which object type for storing the png? There are many to choose: Image, pixbuf, pixmap. A long time I was focused on pixmaps, finally discovered, that the alpha channel was not copied, but just applied to the color values, when rendering the png into the background. Therefore a transfer from pixbuf to pixmap was not a good idea.

2.) To read out single pixel values is a litle complicated on pixbufs. Only way I could see: Change pixbuf to pixmap and thatone to image. (Unless one reads the values directly from memory. But that's not to prefer).

3.) How to get the transparency color into the alpha channel? The hint I got here, thank you very much.

4.) Finally just use

Code: (Plaintext)
1
2
3

gdk_pixbuf_render_to_drawable_alpha(pixbuf,pixmap,0,0,x,y,pixbuf_width,pixbuf_height,0,0,GDK_RGB_DITHER_NONE,0,0)


cu

Croco
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP