I don't know if it does grey scale images (it may convert them to 24 bit
RGB internally if you load one from a file). The create_image_from_data()
routine expects 24-bit RGB image data as well. If all you want to do is
display greyscale data to the screen, you could use the gdkrgb code (which
does handle greyscale images -- it is the display code gimp uses).
You use the draw_gray_image() function in gtk.py for this. It can draw to
any GdkWindow. The GtkDrawingArea widget is probably the one you would
want to draw on. The GtkDrawingArea also has all the draw_*() functions
as methods to make things a bit easier. Here is a bit of example code:
grey_data = "\000\177\377\377\177\000"
da = GtkDrawingArea()
da.size(3,2)
def expose_event(da, event):
da.draw_gray_image(da.get_style[STATE_NORMAL].white_gc,
0,0, 3,2, GDK.RGB_DITHER_NORMAL, grey_data, 3)
return FALSE
da.connect("expose_event", expose_event)
This code can probably be optimised by looking at the area that should be
redrawn and only drawing it without much trouble. There is also a
draw_array() function that will render a Numeric Python array to a
drawable. It takes a nxm or nxmx1 array of unsigned bytes (interpreted as
grey data) or a nxmx3 or nxmx4 array of unsigned bytes (interpreted as RGB
data). It will also handle arrays that have been sliced along the first
two axes, if you only want to display only part of the data. This gives
you all the power of numpy for manipulating the data as well. Note that
pygtk/gnome-python must have been compiled after numpy for this code to be
enabled.
James.
--
Email: [EMAIL PROTECTED]
WWW: http://www.daa.com.au/~james/
On Mon, 18 Oct 1999, Remi Delon wrote:
> Hi, I'm trying to use imlib to display and manipulate greyscale images.
>
> It looks like imlib doesn't support greyscale images very well. Am I wrong ?
>
> For example, the create_image_from_data function only takes a 24 bit image !
>
> Does anyone have any example of greyscale image manipulation with imlib.
>
> Thanks
>
> Remi.
>
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
>
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]