[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [spr2297] need faster bitmap access
Dennis -- please ignore this duplicate message. I forgot to send my
original reply to the Allegro-CL mailing list.
>> I am using X common windows under Allegro CL 3.1.4 on a Sun 4.
>> I create a bit-mapped image and then write it to a file.
>> Currently I'm using the command "window-stream-bit-xy" to read each pixel
>> but this is very slow (168x168 image takes about 45 min.).
>> There is an Xlib command "xgetimage" that should be faster. Is there a
>> way I can access this command through common windows?
Yes, there is. I will assume what you want to do is to save the contents
of a window stream into a file in "X bitmap" format, suitable for munging
by the bitmap(1) program, among others.
I'll also assume the window you want to preserve has no children. (There
are two ways of saving an image, one that copies bits from the parent only,
and one that copies bits from the parent and its children. We implement
the first -- if you need the second we can tell you how to do that too).
What you can do is to create a bitmap, then copy the window stream to the
bitmap. A bitmap's purpose in life is to be an in-Lisp representation of
pixels. (When you copy the window-stream to the bitmap, xlib:get-image is
used). Then you can use save-bitmap to write the bitmap to a Unix file.
(defvar my-window ...)
(defvar unix-file-name ...) ; a string or pathname
(let ((bitmap (make-bitmap :width (window-stream-width my-window)
:height (window-stream-height my-window)
(bitblt my-window 0 0 bitmap 0 0)
(save-bitmap bitmap unix-file-name :format :x11)
Please let us know if this isn't exactly what you want or you have other
-- John Irwin