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