[sugar] how to make a grayscale image?

Benjamin M. Schwartz bmschwar at fas.harvard.edu
Thu Nov 1 20:02:10 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Erik Blankinship wrote:
> Anyone know of an easy technique for turning a pixbuf or cairo context
> into grayscale?

I can't tell what you mean.  Do you mean to take a snapshot of an existing
pixbuf, convert that snapshot to grayscale, and display the snapshot over the
existing pixbuf?  If so, the easiest way I know of is
gtk.gdk.Pixbuf.get_pixels_array and gtk.gdk.pixbuf_new_from_array [1].  These
methods allow you to do math on the pixels as a Numeric Python array, and then
make a new Pixbuf from the resulting array.

1.
http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--get-pixels-array
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKmkCUJT6e6HFtqQRAgrjAJ47VHqmT9j7xVAyNzgKXdgDTxQWMQCffJ6k
D26RDImuualfzAdlJNaP4k0=
=Oc7S
-----END PGP SIGNATURE-----


More information about the Sugar mailing list