Re: MIT-SHM example



Paul, what do you say about this?

From: Olexiy Avramchenko <ath beast stu cn ua>
To: Patrice St-Gelais <patrice st-gelais oricom ca>
Cc: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
Subject: Re: Hints needed about drawing lines and arcs
Date: Wed, 06 Nov 2002 12:25:00 +0200

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 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

_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.




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