[pygtk] Displayed gtk.Image have fewer colors than the source pixbuf

Pontus Ekberg pontus.ekberg.7897 at student.uu.se
Sat Jan 14 03:21:17 WST 2006


Stephen Langer wrote:
> How are you displaying the image?  Is it antialiased?
> 
>   -- Steve
> 
> On Jan 12, 2006, at 6:55 PM, Pontus Ekberg wrote:
> 
> 
>>I am writing an image viewer that uses PyGTK. The displayed images do
>>not look as good as expected though. When there should be soft
>>transitions between colors I get stripes instead, as if the number of
>>colors that can be displayed is limited to a relativly low number.
>>
>>For an example look at these two images.
>>
>>This is how it should look: http://home.student.uu.se/poek7897/ 
>>nice.png
>>
>>This is how it is displayed: http://home.student.uu.se/poek7897/ 
>>ugly.png
>>
>>I know there is nothing wrong with the pixbuf, for if I save it to a
>>file right before I do the gtk.Image.set_from_pixbuf() it will have  
>>all
>>the colors intact.
>>
>>I figured there might be something I should do with  
>>gtk.gdk.colormap or
>>gtk.gdk.Visual, but I have tried everything I can think of with a few
>>seg faults as the only results.
>>
>>I have also noticed that some other GTK image viewers have the exact
>>same problem, while some others have not. I know some C programs with
>>the problem and some without, but I have not found any in PyGTK that
>>have solved it. Looking at the code for these C programs have not  
>>given
>>me any ideas though.
>>
>>Any ideas on the cause of this?
>>
>>Regards,
>>Pontus Ekberg

I am displaying it by simply doing this (where self.image is a gtk.Image):

	self.image.set_from_pixbuf(pixbuf)
	self.image.show()

There seems to be nothing wrong with the pixbuf used as I wrote earlier,
I can even retrieve it with `self.image.get_pixbuf()` and save it to a
file with all image data intact and looking well.

I have not found any information on the subject of antialiased images
other than something on the mail archives concerning GnomeCanvas. The
application I'm writing is not GNOME specific though, so there are no
gnome libraries available for use. Besides, other applications (gqview
for an example) handle these images perfectly without GNOME.

I'm sorry for the double posting earlier, me and the SMTP server are not
the best of friends.

Regards,
Pontus Ekberg





More information about the pygtk mailing list