Re: Hints needed about drawing lines and arcs



Patrice St-Gelais wrote:

Hi all,

I am working on an application which needs to process16 bit greyscale
images.

The image is stored in a kind of raw buffer (actually an unsigned short
int*).  It is displayed by drawing it in a GdkPixmap* with
gdk_draw_gray_image after cutting the depth to 8 bits, then emitting an
"expose_event" for the gtk_drawing_area.  This event launches a callback
which transfers the pixmap to the drawing area gdk_window with
gdk_draw_pixmap.

I use GTK 1.2.X.

I want to draw lines and arcs of variable thickness in the 16 bits
buffer, without reinventing the wheel.

GDK offers some drawing primitives, but as I understand them, they allow
drawing in "drawables" like GDK pixmaps or windows, which are structures
on the X Server side.  I cannot easily, or at least efficiently,
retrieve the result of the drawing in the client side with the intent to
combine it with other client side images or to save it, for instance, in
a PNG file - or can I?  Furthermore, if I could, it wouldn't be a 16
bits image, or am I wrong?

Any advice on using GTK/GDK for this, or on any alternate solution,
would be welcomed.

I'm using MIT-SHM X extension for this purpose. As result I can use both GDK
drawing primitives and raw memory access.

You have to:
1) Create a shared image *XShmCreateImage()*. This gives you raw access.
2) Get SHM pixmap of this image *XShmCreatePixmap()*. This gives you X drawable.
3) Use GDK function *gdk_pixmap_foreign_new()* to obtain usual GDK pixmap.

*Note* this will only work when you run your app on the same box with Xserver.

You can read about MIT-SHM at:
http://ftp.xfree86.org/pub/XFree86/4.2.1/doc/mit-shm.TXT

Olexiy





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]