GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 30, 2014 11:37 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [Solved] Read png with transparent color
PostPosted: Sun Jan 06, 2008 5:04 pm 
Offline

Joined: Fri Jan 04, 2008 7:29 am
Posts: 4
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.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 08, 2008 3:26 pm 
Offline

Joined: Fri Jan 04, 2008 7:29 am
Posts: 4
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:
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group