\HeaderA{dev2bitmap}{Graphics Device for Bitmap Files via GhostScript}{dev2bitmap}
\aliasA{bitmap}{dev2bitmap}{bitmap}
\keyword{utilities}{dev2bitmap}
\begin{Description}\relax
\code{bitmap} generates a graphics file.
\code{dev2bitmap} copies the current graphics device to a file in a
graphics format.
\end{Description}
\begin{Usage}
\begin{verbatim}
bitmap(file, type = "png256", height = 7, width = 7, res = 72,
       units = "in", pointsize, ...)

dev2bitmap(file, type = "png256", height = 7, width = 7, res = 72,
           units = "in", pointsize, ...,
           method = c("postscript", "pdf"))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{file}] The output file name, with an appropriate extension.
\item[\code{type}] The type of bitmap. the default is \code{"png256"}.
\item[\code{width, height}] Dimensions of the display region.
\item[\code{res}] Resolution, in dots per inch.
\item[\code{units}] The units in which \code{height} and \code{width} are
given.  Can be \code{in} (inches), \code{px} (pixels), \code{cm} or
\code{mm}.
\item[\code{pointsize}] The pointsize to be used for text: defaults to
something reasonable given the width and height
\item[\code{...}] Other parameters passed to \code{\LinkA{postscript}{postscript}} or
\code{\LinkA{pdf}{pdf}}.
\item[\code{method}] Should the plot be done by \code{\LinkA{postscript}{postscript}} or
\code{\LinkA{pdf}{pdf}}?
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{dev2bitmap} works by copying the current device to a
\code{\LinkA{postscript}{postscript}} or \code{\LinkA{pdf}{pdf}} device, and
post-processing the output file using \code{ghostscript}.
\code{bitmap} works in the same way using a \code{postscript} device
and post-processing the output as \sQuote{printing}.

You will need \code{ghostscript}: the full path to the executable can
be set by the environment variable \env{R\_GSCMD}.
(If this is unset the command \code{"gs"} is used, which will work if
it is in your path.)

The types available will depend on the version of \code{ghostscript},
but are likely to include
\code{"pcxmono"}, \code{"pcxgray"}, \code{"pcx16"}, \code{"pcx256"},
\code{"pcx24b"}, \code{"pcxcmyk"}, \code{"pbm"}, \code{"pbmraw"},
\code{"pgm"}, \code{"pgmraw"}, \code{"pgnm"}, \code{"pgnmraw"},
\code{"pnm"}, \code{"pnmraw"}, \code{"ppm"}, \code{"ppmraw"},
\code{"pkm"}, \code{"pkmraw"}, \code{"tiffcrle"}, \code{"tiffg3"},
\code{"tiffg32d"}, \code{"tiffg4"}, \code{"tifflzw"},
\code{"tiffpack"}, \code{"tiff12nc"}, \code{"tiff24nc"},
\code{"psmono"}, \code{"psgray"}, \code{"psrgb"}, \code{"bit"},
\code{"bitrgb"}, \code{"bitcmyk"}, \code{"pngmono"}, \code{"pnggray"},
\code{"png16"}, \code{"png256"}, \code{"png16m"}, \code{"jpeg"},
\code{"jpeggray"}, \code{"pdfwrite"}.

For formats which contain a single image, a file specification like
\code{Rplots\%03d.png} can be used: this is interpreted by GhostScript.

For \code{dev2bitmap} if just one of \code{width} and \code{height} is
specified, the other is chosen to preserve aspect ratio of the
device being copied.  The main reason to prefer \code{method = "pdf"}
over the default would be to allow semi-transparent colours to be used.

For graphics parameters such as \code{"cra"} that need to work in
pixels, the default resolution of 72dpi is always used.
\end{Details}
\begin{Value}
None.
\end{Value}
\begin{Section}{Conventions}
This section describes the implementation of the conventions for
graphics devices set out in the \dQuote{R Internals Manual}.  These
devices follow the underlying device, so when viewed at the stated
\code{res}:

\Itemize{
\item The default device size is 7 inches square.
\item Font sizes are in big points.
\item The default font family is (for the standard GhostScript
setup) URW Nimbus Sans.
\item Line widths are as a multiple of 1/96 inch, with no minimum. 
\item Circle of any radius are allowed.
\item Colours are interpreted by the viewing/printing application.
}
\end{Section}
\begin{SeeAlso}\relax
\code{\LinkA{savePlot}{savePlot}}, which for \code{windows} and
\code{X11(type = "Cairo")} provides a simple way to record a PNG
record of the current plot.

\code{\LinkA{postscript}{postscript}}, \code{\LinkA{pdf}{pdf}}, \code{\LinkA{png}{png}} and
\code{\LinkA{jpeg}{jpeg}} and on Windows \code{bmp}.

To display an array of data, see \code{\LinkA{image}{image}}.
\end{SeeAlso}

