[plt-scheme] bitmaps as bytes or ports

From: Jon Zeppieri (zeppieri at gmail.com)
Date: Fri May 15 15:00:37 EDT 2009

On Fri, May 15, 2009 at 2:55 PM, David Van Horn <dvanhorn at ccs.neu.edu> wrote:
> Using load-file and save-file it is possible to create and save bitmap%s
>  from file.  Is it possible to do the same with a port or byte string?
>
> I am trying to write a function that takes an image-snip% and base 64
> encodes the contents of its bitmap in a given format.
>
> (base64-encode (send (send image get-bitmap) save-bytes 'jpeg))
>
> But I don't see how to do save-bytes.


Maybe I'm misunderstanding your question, but there are read-bytes and
write-bytes procedures for doing binary I/O on ports:

http://docs.plt-scheme.org/reference/Byte_and_String_Input.html#(def._((quote._~23~25kernel)._read-bytes))
http://docs.plt-scheme.org/reference/Byte_and_String_Output.html#(def._((quote._~23~25kernel)._write-bytes))

-jaz


Posted on the users mailing list.