On 12/07/10 08:16, Andrew wrote:
> On 12/07/10 00:01, Tim Evans wrote:
>> On 2010-07-11 4:19, Andrew wrote:
>>> Hi guys,
>>>
>>> In this example, a small gtk.gdk.Pixbuf is copied onto a larger pixbuf
>>> however where on the small pixbuf, there is transparency, this is
>>> converted to the gtk background colour.
>>>
>>> This means when the small pixbuf is copied 3 times and overlaid (as in
>>> the example), it looks incorrect. How do I make it so that the
>>> transparency in the small pixbuf is not replaced with the gtkbackground
>>> colour?
>>
>> You need to use the 'composite' method rather than copy_area. I would
>> provide example code, but the arguments are a bit complex and I'd be
>> sure to get them wrong the first time and confuse you.
>>
>
> I am afraid that didn't work either. It now gives me the image shown in
> the screenshot attached. Below is my code.
>
>
> Is there a way to do this successfully or do I need to use cairo or
> something? (I must mention that the pixbufs I retrieve from a
> gtk.Icontheme are SVGs, if this makes any difference)
>
>
>
> #!/usr/bin/env python
> import gtk
> from gtk import gdk as gdk
>
> small = 16
> counter = 0
> offset = 4
> large = 24
>
> if __name__ == "__main__":
>
> icon_theme = gtk.icon_theme_get_default();
>
> small_pixbuf = icon_theme.load_icon("image", small, ());
>
> large_pixbuf = icon_theme.load_icon("image", large, ());
>
> large_pixbuf.fill(0x000000);
>
> small_pixbuf_buffer = small_pixbuf.copy()
> small_pixbuf.composite(large_pixbuf, 0, 0, 24, 24, 0, 0, 1, 1,
> gdk.INTERP_NEAREST, 255);
> small_pixbuf_buffer = small_pixbuf.copy()
> small_pixbuf.composite(large_pixbuf, 0, 0, 24, 24, 4, 4, 1, 1,
> gdk.INTERP_NEAREST, 255);
> small_pixbuf_buffer = small_pixbuf.copy()
> small_pixbuf.composite(large_pixbuf, 0, 0, 24, 24, 8, 8, 1, 1,
> gdk.INTERP_NEAREST, 255);
>
> window = gtk.Window()
> image = gtk.Image()
> image.set_from_pixbuf(large_pixbuf)
> window.add(image)
> window.show_all()
> window.connect("delete-event", gtk.main_quit)
> gtk.main()
>
Sorry to BUMP this guys but does anyone have any idea why this is
happening, your reply doesn't have to be a fix. Any bugs/documentation
you can point me to?
--
Andrew
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/