From: Chris Perkins
Subject: Graphic Operations and Display
Date: 
Message-ID: <8grZ7.9559$75.958943@news.uswest.net>
I'm prototyping something in LispWorks (for Windows) and it is moving along
quite nicely.

But I'm to a point now where I need to do some operations on pixel graphic
data.  I am hoping to keep all of this work in Lisp, rather than have to
jump to C.

Here is my dilemma:  In LispWorks one can load an image from file and draw
it easily enough (gp:load-image, gp:draw-image) but I can't seem to get
access to the raw data of the bitmap.

Or, I can easily define a byte array and load up a file myself, but then I
cannot figure out how to get it drawn onscreen.

The only solution I've seen so far is to load the graphic data, perform the
operations I need, write it back out to disk, and then have CAPI load it for
viewing.  But that's terribly inelegant.

I hope I'm overlooking something obvious.  Can anyone point me in the right
direction?

Thanks,

Chris

From: Wade Humeniuk
Subject: Re: Graphic Operations and Display
Date: 
Message-ID: <a15io0$isa$1@news3.cadvision.com>
There is more than one way of doing this.

First read up on:

gp:read-external-image
gp:convert-external-image
gp:read-and-convert-external-image

gp:load-image may be too strong, gp:read-external-image just returns a
strcuture with an array of data (the raw bitmap).

Now...

Choice 1
You can just twiddle the pixels directly on the pixmap-port
(capi:output-pane) using gp:draw-point.  I assume you are not doing this as
the point operations are slow.

Coice #2
You can use gp:create-pixmap-port which creates a memoryDC (in Windows
terms).  With this port you can access the pixels using gp:draw-point or any
of the other gp:draw-* operations.  When you are done you can use a
gp:pixblt or gp:copy-pixels to display the result in a capi:output-pane.  I
am unsure of how fast these operations are on a pixmap-port but you could
try.

Choice #3

Pixel operations (your own code) to operate on gp:external-image.
gp:read-external-image returns gp:external-image.  The slot data on
gp:read-external-image is the bytes in the bitmap file.  You can create a
gp:external-image with data you generated yourself.  To display in on a port
use gp:convert-external-image and then you can use draw-image on the
converted image.

Choice #4

Pixel operations (your own code) to operate on gp:image.
gp:read-and-convert-external-image returns gp:image. gp:draw-image (as
usual)

IF you want to inspect the image classes directly on it you can do something
like:

(setf port (capi:contain (make-instance 'capi:output-pane)))
(setf external-image (gp:read-external-image "yourfile.bmp"))
(setf image (gp:read-and-convert-external-image port "yourfile.bmp"))

(describe image) and (describe external-image) or
(capi:display (make-instance 'lispworks-tools:inspector :object image))

Look at the slot representation, in there is the bits.    You will have to
write rountines to manipulate the bitmap directly.

You can also open a class browser and browse the class gp:image and
gp:dib-section.

It would up to you to manipulate gp:external-image or gp:image.

Good Luck

Wade

"Chris Perkins" <········@medialab.com> wrote in message
·························@news.uswest.net...
> I'm prototyping something in LispWorks (for Windows) and it is moving
along
> quite nicely.
>
> But I'm to a point now where I need to do some operations on pixel graphic
> data.  I am hoping to keep all of this work in Lisp, rather than have to
> jump to C.
>
> Here is my dilemma:  In LispWorks one can load an image from file and draw
> it easily enough (gp:load-image, gp:draw-image) but I can't seem to get
> access to the raw data of the bitmap.
>
> Or, I can easily define a byte array and load up a file myself, but then I
> cannot figure out how to get it drawn onscreen.
>
> The only solution I've seen so far is to load the graphic data, perform
the
> operations I need, write it back out to disk, and then have CAPI load it
for
> viewing.  But that's terribly inelegant.
>
> I hope I'm overlooking something obvious.  Can anyone point me in the
right
> direction?
>
> Thanks,
>
> Chris
>
>
From: Chris Perkins
Subject: Re: Graphic Operations and Display
Date: 
Message-ID: <6RuZ7.9597$75.1020231@news.uswest.net>
Wade,

Thanks - that was exactly the information I was looking for.  I must have
read past external-image when looking around for a solution.  Thanks a
million.

Chris