On 2010-07-21 19:24, Andrew wrote:

Thanks for the reply.

That doesn't seem to work for me, it gives the image attached. I have
also tried this with other icon themes (GNOME, Tango) and the results
are still similiar.

Is this just a bug in GTK?


I can't be sure, but it looks like the image returned by render_icon with size 'button' is 16-by-16 for you, whereas it's 20-by-20 for me. I guess your system is configured differently. This means that sampling a 20-by-20 area in composite gets some pixels that are outside the area of the icon. Try this for the general case:

  small = widget.render_icon('gtk-ok', 'button')
  w = small.get_width()
  h = small.get_height()
  large = gtk.gdk.Pixbuf('rgb', True, 8, 10 + w, 10 + h)
  large.fill(0)
  assert large.get_has_alpha()
  assert small.get_has_alpha()
  small.composite(large, 0, 0, w, h, 0, 0, 1, 1, 'nearest', 255)
  small.composite(large, 5, 5, w, h, 5, 5, 1, 1, 'nearest', 255)
  small.composite(large, 10, 10, w, h, 10, 10, 1, 1, 'nearest', 255)
  large.save('test.png', 'png')

Personally I would consider the behaviour of composite when sampling an area larger than the scaled source to be a minor bug. It can be worked around pretty easily, but I can't imagine any situation where the current behaviour would be useful. As you've demonstrated it can be higher counter-intuitive.

--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to