[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to display image arrays in 8bit window?
- To: Dave Bright <email@example.com>
- Subject: How to display image arrays in 8bit window?
- From: firstname.lastname@example.org (Bill St. Clair)
- Date: Fri, 9 Oct 1992 12:09:22 -0500
- Cc: Ranson <ranson@LANNION.cnet.fr>, info-mcl
>Date: 1 Oct 92 14:15:00 EST
>From: "BRIGHT" <email@example.com>
>Subject: How to display image arrays in 8bit window?
>To: "info-mcl" <firstname.lastname@example.org>
>Having just recently upgraded from 1.3.2,
>I would appreciate code or tips for this:
>To display arrays of numbers as images with MCL2.
>I've tried picture-files.lisp in the MCL:examples folder on the CDRom,
>which works great for .pict files (both 8 and 24 bit!).
>I would like to do image processing with arrays in LISP and display them
>in a color window, but I know NOTHNG about handles, etc. Are there functions
>around that will display arrays to a window with pixels at least 8 bits deep?
>I've rummaged around in the CD Rom and some of the mail archives, but could
>easily have missed the goods.
>X400-Received: by /PRMD=inria/ADMD=atlas/C=FR/; Relayed; 09 Oct 92 08:17:35+0100
>X400-Received: by /PRMD=CNET/ADMD=ATLAS/C=FR/; Relayed; 09 Oct 92 08:17:00 GMT
>Date: 09 Oct 92 08:17:00 GMT
>From: Ranson <ranson@LANNION.cnet.fr>
>To: email@example.com, firstname.lastname@example.org
>Subject: Re: How to display image arrays in 8bit window?
>This is not easy to explain if you haven't read Inside Mac. A starting point
>would be to look at technical note 120 (Principia Offscreen), that is on the
>MCL CD. It explains how you can create an offscreen pixmap, in which you will
>be able to stuff your values as if in an array. If the code looks complicated,
>look at the part about GWorlds. GWorlds exists in System 7 or when 32-bit QD
>Once you have your pixmap, you can display it on screen with CopyBits.
Someone else asked the same question a number of months ago and noone
gave a (public) response that I remember. Though Daniel's solution is
certainly viable, it probably is not what Dave was looking for. My
interpretation of his message is that he has a bunch of Lisp code that
creates two-dimensional arrays of 8-bit integers and he wants to
display these arrays on the screen. This means copying them either to
an off-screen pixmap or to a PICT file (which solution you use depends
on how big the arrays are and how much memory is in your machine).
I started once writing some code to do this, but never finished. There
are lots of fence-post problems. I don't have time to finish that code
now, but I can help in writing low-level byte-moving routines to speed
up the following (after someone else gets the rest of it working):
(defun copy-byte-array-to-macptr (array array-start array-end
(let ((p-offset macptr-offset)
(when (>= a-offset array-end) (return))
(setf (%get-byte macptr p-offset) (aref array a-offset))
If you decide to write your arrays to a PICT file, I can help with
speeding up the following code (if you find that it's too slow):
(defun write-byte-array (array start end stream)
(let ((offset start))
(multiple-value-bind (writer arg) (stream-writer stream)
(when (>= offset end) (return))
(funcall writer arg (aref array offset))))))
In order to use either of the above two functions on a two-dimensional
array, you'll need to get the one-dimensional array in which its
contents are stored. A multi-dimensional array is just a header containing
a pointer to a one-dimensional array and information about the dimensions.
Information in the one dimensional array is stored with the last
dimension varying the fastest (I never remember if this is called
row-major or column-major).
returns two values:
1) a one-dimensional simple array containing the data for ARRAY
2) an offset into value 1 for the first element of ARRAY (usually 0)
I know very little about the palette manager. What little I DO know is
encoded in "ccl:examples;picture-files.lisp". You'll probably want to
create custom palettes. You'll either have to study the palette manager
chapter of IM V or find someone who has written some code already.