[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Graphics to Bitmaps
The task of the week is to perform simple bitmap-driven animation on the Symbolics.
A standard way to do this is to have a bitmap buffer, draw graphics and bitblt
bitmap patches into the buffer, and then bitblt the buffer to the screen.
This requires the ability to draw graphics onto a bit array. The function
(tv:with-output-to-bitmap (dummy-stream) body-using-dummy-stream) allocates
and returns its own bitmap. The documentation for a different function,
(tv:with-output-to-bitmap-stream (bitmap-stream) body-using-bitmap-stream),
says that bitmap-stream is "A stream that is a raster array intended to hold
the image generated by body." Thus the sequence
(setq my-array (graphics:make-raster-array-with-correct-width my-width my-height
:element-type '(unsigned-byte 1)))
(graphics:draw-circle 10 10 5 :stream my-array))
was expected to produce the right behavior. It didn't. Apparently
tv:with-output-to-bitmap-stream also insists on allocating its own array.
What is the right sequence to do what I want to do? The current
work-around is to accept the new array from tv:with-output-to-bitmap
and then bitblt copy it into my personal array buffer (instead of
drawing the graphics there directly). This is inefficient.
Assuming I can draw graphics directly into a bitmap, do the graphics
clip to the edges of the bitmap automatically?
The manual recommends (tv:make-sheet-bit-array) for allocating arrays.
(tv:make-sheet-bit-array *standard-output* 10 10) barfs with "<stream>
not an instance". What's the difference between a sheet-bit-array and
a regular bit-array--is one faster? make-raster-array-with-correct-width
seems to work O.K. now--can I improve its speed by shifting to "sheet arrays"?
Currently I do output with (send my-window :bitblt tv:alu-seta width height
my-bitmap 0 0 target-x target-y). There is also the plain (bitblt) function,
some kind of ":draw-1-bit-raster" method, and the (graphics:draw-image)
function. What do most people use for fast, vanilla b&w output to a screen?
Bonus problem: How to draw a bitmap at your current place in a Lisp Listener.
(graphics:with-graphics-scale (stream 1.0 -1.0)
(graphics:draw-image my-bitmap 0 0 :stream stream)))
almost works but runs into the infamous "ha ha, you left the cursor up
at the top of with-room-for-graphics" problem, it prints a white line and
wipes out part of the bitmap. I forget the magic to take care of this.
Is there a clean way around it or a cleaner way of doing it?
Any and all help appreciated,
John Myers firstname.lastname@example.org