Re: how to create a binary output stream in SBCL



Trastabuga <lispercat@xxxxxxxxx> writes:

I am trying to write an image to the stream so when I do this:
(let ((s (make-string-output-stream :element-type '(unsigned-byte
8))))
(write-jpeg-to-stream s :image my-image))

Lisp complains: #<SB-IMPL::STRING-OUTPUT-STREAM {C939499}> is not a
binary output stream.

How can I make a binary output stream?

There isn't a built-in way to make a binary in-memory output
stream. It's pretty easy to make one for a file on disk:

(with-open-file (stream "file.jpg"
:direction :output
:element-type '(unsigned-byte 8))
(write-jpeg-to-stream s :image my-image))

Flexi-streams is a library that will let you make a binary in-memory
stream.

Zach
.