From: Trastabuga
Subject: how to create a binary output stream in SBCL
Date: 
Message-ID: <1180485001.295143.192880@w5g2000hsg.googlegroups.com>
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?

Thank you,
Andrew

From: Zach Beane
Subject: Re: how to create a binary output stream in SBCL
Date: 
Message-ID: <m3tztv2lm5.fsf@unnamed.xach.com>
Trastabuga <·········@gmail.com> 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
From: Duane Rettig
Subject: Re: how to create a binary output stream in SBCL
Date: 
Message-ID: <o0ejkyesv0.fsf@gemini.franz.com>
Trastabuga <·········@gmail.com> 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?

Simple-streams (from Allegro CL, but also available to some extent on
other lisps) defines a buffer-output-simple-stream - see
http://www.franz.com/support/documentation/8.0/doc/classes/excl/buffer-output-simple-stream.htm
which is analogous to a string-stream.  Also available are the
functions with-output-to-buffer and make-buffer-output-stream, linked
from that page.

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182