Re: [Rd] serialized plot object (for a certain device)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sat, 01 Sep 2007 16:59:47 +0100 (BST)

On Sat, 1 Sep 2007, Tobias Verbeke wrote:

> Dear list,
>
> Using serialize it is possible to save
> the binary string representing an R
> object to a raw R vector.
>
> ## adapted from ?serialize
> x <- serialize(list(1,2,3), NULL)
> x
>
> I am looking for a way to capture
> the binary string that in normal
> use of graphics devices will be
> written to (most commonly) a file
> connection.

Nope, unfortunately, they write to files not connections and no R object is involved.

> jpeg(file = "test.jpg")
> plot(1:10)
> dev.off()
>
> In other words, is there a way of
> capturing the binary `jpeg string'
> representing the plot(1:10) graph,
> e.g. into a raw vector ?

Only by rewriting the jpeg library used to write the file. In the case of jpeg it is done here:

   /* Step 2: specify data destination (eg, a file) */    jpeg_stdio_dest(&cinfo, outfile);

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat 01 Sep 2007 - 16:05:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 01 Sep 2007 - 16:40:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.