| 42333 |
ripley |
1 |
% File src/library/grDevices/man/dev2bitmap.Rd
|
|
|
2 |
% Part of the R package, http://www.R-project.org
|
| 59522 |
ripley |
3 |
% Copyright 1995-2012 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 27442 |
ripley |
6 |
\name{dev2bitmap}
|
| 56186 |
murdoch |
7 |
\alias{dev2bitmap}
|
| 27442 |
ripley |
8 |
\alias{bitmap}
|
| 52776 |
hornik |
9 |
\title{Graphics Device for Bitmap Files via Ghostscript}
|
| 27442 |
ripley |
10 |
\usage{
|
| 45564 |
ripley |
11 |
bitmap(file, type = "png16m", height = 7, width = 7, res = 72,
|
| 45559 |
ripley |
12 |
units = "in", pointsize, taa = NA, gaa = NA, \dots)
|
| 30915 |
ripley |
13 |
|
| 45564 |
ripley |
14 |
dev2bitmap(file, type = "png16m", height = 7, width = 7, res = 72,
|
| 44236 |
ripley |
15 |
units = "in", pointsize, \dots,
|
| 45564 |
ripley |
16 |
method = c("postscript", "pdf"), taa = NA, gaa = NA)
|
| 27442 |
ripley |
17 |
}
|
|
|
18 |
\arguments{
|
|
|
19 |
\item{file}{The output file name, with an appropriate extension.}
|
| 59092 |
murdoch |
20 |
\item{type}{The type of bitmap.}
|
| 41264 |
ripley |
21 |
\item{width, height}{Dimensions of the display region.}
|
| 27442 |
ripley |
22 |
\item{res}{Resolution, in dots per inch.}
|
| 41264 |
ripley |
23 |
\item{units}{The units in which \code{height} and \code{width} are
|
|
|
24 |
given. Can be \code{in} (inches), \code{px} (pixels), \code{cm} or
|
|
|
25 |
\code{mm}.}
|
| 27442 |
ripley |
26 |
\item{pointsize}{The pointsize to be used for text: defaults to
|
|
|
27 |
something reasonable given the width and height}
|
| 41245 |
ripley |
28 |
\item{\dots}{Other parameters passed to \code{\link{postscript}} or
|
|
|
29 |
\code{\link{pdf}}.}
|
|
|
30 |
\item{method}{Should the plot be done by \code{\link{postscript}} or
|
|
|
31 |
\code{\link{pdf}}?}
|
| 45564 |
ripley |
32 |
\item{taa, gaa}{Number of bits of antialiasing for text and for graphics
|
|
|
33 |
respectively. Usually 4 (for best effect) or 2. Not supported on
|
|
|
34 |
all types.}
|
| 27442 |
ripley |
35 |
}
|
|
|
36 |
\description{
|
|
|
37 |
\code{bitmap} generates a graphics file.
|
|
|
38 |
\code{dev2bitmap} copies the current graphics device to a file in a
|
|
|
39 |
graphics format.
|
|
|
40 |
}
|
|
|
41 |
\details{
|
|
|
42 |
\code{dev2bitmap} works by copying the current device to a
|
| 41245 |
ripley |
43 |
\code{\link{postscript}} or \code{\link{pdf}} device, and
|
|
|
44 |
post-processing the output file using \code{ghostscript}.
|
|
|
45 |
\code{bitmap} works in the same way using a \code{postscript} device
|
| 42961 |
ripley |
46 |
and post-processing the output as \sQuote{printing}.
|
| 27442 |
ripley |
47 |
|
| 41245 |
ripley |
48 |
You will need \code{ghostscript}: the full path to the executable can
|
| 60456 |
murdoch |
49 |
be set by the environment variable \env{R_GSCMD}. If this is unset, a
|
| 58206 |
ripley |
50 |
GhostScript executable will be looked for by name on your path: on a
|
|
|
51 |
Unix alike \code{"gs"} is used, and on Windows the setting of the
|
|
|
52 |
environment variable \env{GSC} is used, otherwise commands
|
|
|
53 |
\code{"gswi64c.exe"} then \code{"gswin32c.exe"} are tried.
|
| 27442 |
ripley |
54 |
|
|
|
55 |
The types available will depend on the version of \code{ghostscript},
|
|
|
56 |
but are likely to include
|
|
|
57 |
\code{"pcxmono"}, \code{"pcxgray"}, \code{"pcx16"}, \code{"pcx256"},
|
|
|
58 |
\code{"pcx24b"}, \code{"pcxcmyk"}, \code{"pbm"}, \code{"pbmraw"},
|
|
|
59 |
\code{"pgm"}, \code{"pgmraw"}, \code{"pgnm"}, \code{"pgnmraw"},
|
|
|
60 |
\code{"pnm"}, \code{"pnmraw"}, \code{"ppm"}, \code{"ppmraw"},
|
|
|
61 |
\code{"pkm"}, \code{"pkmraw"}, \code{"tiffcrle"}, \code{"tiffg3"},
|
|
|
62 |
\code{"tiffg32d"}, \code{"tiffg4"}, \code{"tifflzw"},
|
| 55711 |
ripley |
63 |
\code{"tiffpack"}, \code{"tiff12nc"}, \code{"tiff24nc"}, \code{"tiff32nc"}
|
| 27442 |
ripley |
64 |
\code{"psmono"}, \code{"psgray"}, \code{"psrgb"}, \code{"bit"},
|
|
|
65 |
\code{"bitrgb"}, \code{"bitcmyk"}, \code{"pngmono"}, \code{"pnggray"},
|
| 45564 |
ripley |
66 |
\code{"pngalpha"}, \code{"png16"}, \code{"png256"}, \code{"png16m"},
|
|
|
67 |
\code{"png48"}, \code{"jpeg"}, \code{"jpeggray"}, \code{"pdfwrite"}.
|
| 61433 |
ripley |
68 |
|
| 55711 |
ripley |
69 |
The default type, \code{"png16m"}, supports 24-bit colour and
|
| 45564 |
ripley |
70 |
anti-aliasing. Versions of \R prior to 2.7.0 defaulted to
|
| 48291 |
ripley |
71 |
\code{"png256"}, which uses a palette of 256 colours and could be a
|
|
|
72 |
more compact representation. Monochrome graphs can use
|
| 45564 |
ripley |
73 |
\code{"pngmono"}, or \code{"pnggray"} if anti-aliasing is desired.
|
| 55711 |
ripley |
74 |
Plots with a transparent background and varying degrees of
|
|
|
75 |
transparency should use \code{"pngalpha"}.
|
| 48291 |
ripley |
76 |
|
|
|
77 |
Note that for a colour TIFF image you probably want \code{"tiff24nc"},
|
|
|
78 |
which is 8-bit per channel RGB (the most common TIFF format). None of
|
| 55711 |
ripley |
79 |
the listed TIFF types support transparency. \code{"tiff32nc"} uses
|
|
|
80 |
8-bit per channel CMYK, which printers might require.
|
| 61433 |
ripley |
81 |
|
| 27442 |
ripley |
82 |
For formats which contain a single image, a file specification like
|
| 52776 |
hornik |
83 |
\code{Rplots\%03d.png} can be used: this is interpreted by Ghostscript.
|
| 27442 |
ripley |
84 |
|
|
|
85 |
For \code{dev2bitmap} if just one of \code{width} and \code{height} is
|
|
|
86 |
specified, the other is chosen to preserve aspect ratio of the
|
| 41245 |
ripley |
87 |
device being copied. The main reason to prefer \code{method = "pdf"}
|
|
|
88 |
over the default would be to allow semi-transparent colours to be used.
|
| 40455 |
ripley |
89 |
|
| 40573 |
ripley |
90 |
For graphics parameters such as \code{"cra"} that need to work in
|
|
|
91 |
pixels, the default resolution of 72dpi is always used.
|
|
|
92 |
|
| 40455 |
ripley |
93 |
#ifdef windows
|
| 47259 |
ripley |
94 |
Paths for \code{file} and \env{R_GSCMD} which contain spaces are
|
| 46889 |
ripley |
95 |
mapped to short names \emph{via} \code{\link{shortPathName}}.
|
| 48291 |
ripley |
96 |
#endif
|
| 27442 |
ripley |
97 |
}
|
|
|
98 |
\value{
|
|
|
99 |
None.
|
|
|
100 |
}
|
|
|
101 |
|
| 51145 |
ripley |
102 |
\note{
|
| 27442 |
ripley |
103 |
#ifdef windows
|
|
|
104 |
Use of \code{bitmap} will leave a temporary file (with file name
|
| 51145 |
ripley |
105 |
starting \code{Rbit}).
|
| 61433 |
ripley |
106 |
|
| 51145 |
ripley |
107 |
#endif
|
|
|
108 |
Although using \code{type = "pdfwrite"} will work for simple plots, it
|
|
|
109 |
is not recommended. Either use \code{\link{pdf}} to produce PDF
|
|
|
110 |
directly, or call \command{ps2pdf -dAutoRotatePages=/None} on the
|
|
|
111 |
output of \code{\link{postscript}}: that command is optimized to do
|
|
|
112 |
the conversion to PDF in ways that these functions are not.
|
| 27442 |
ripley |
113 |
}
|
|
|
114 |
|
| 44566 |
ripley |
115 |
\section{Conventions}{
|
|
|
116 |
This section describes the implementation of the conventions for
|
|
|
117 |
graphics devices set out in the \dQuote{R Internals Manual}. These
|
|
|
118 |
devices follow the underlying device, so when viewed at the stated
|
|
|
119 |
\code{res}:
|
|
|
120 |
|
|
|
121 |
\itemize{
|
|
|
122 |
\item The default device size is 7 inches square.
|
|
|
123 |
\item Font sizes are in big points.
|
| 52776 |
hornik |
124 |
\item The default font family is (for the standard Ghostscript
|
| 44566 |
ripley |
125 |
setup) URW Nimbus Sans.
|
| 61433 |
ripley |
126 |
\item Line widths are as a multiple of 1/96 inch, with no minimum.
|
| 44566 |
ripley |
127 |
\item Circle of any radius are allowed.
|
|
|
128 |
\item Colours are interpreted by the viewing/printing application.
|
|
|
129 |
}
|
|
|
130 |
}
|
|
|
131 |
|
| 27442 |
ripley |
132 |
\seealso{
|
| 44566 |
ripley |
133 |
\code{\link{savePlot}}, which for \code{windows} and
|
| 55869 |
ripley |
134 |
\code{X11(type = "cairo")} provides a simple way to record a PNG
|
| 44566 |
ripley |
135 |
record of the current plot.
|
| 61433 |
ripley |
136 |
|
| 50574 |
ripley |
137 |
\code{\link{postscript}}, \code{\link{pdf}}, \code{\link{png}},
|
|
|
138 |
\code{\link{jpeg}}, \code{\link{tiff}} and \code{bmp}.
|
| 27442 |
ripley |
139 |
|
|
|
140 |
To display an array of data, see \code{\link{image}}.
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
\keyword{utilities}
|