# R: Graphics Device for Bitmap Files via GhostScript

dev2bitmap {grDevices} | R Documentation

## Graphics Device for Bitmap Files via GhostScript

### Description

`bitmap` generates a graphics file. `dev2bitmap` copies the current graphics device to a file in a graphics format.

### Usage

    bitmap(file, type = "png256", height = 6, width = 6, res = 72,
           units = "in", pointsize, ...)

    dev2bitmap(file, type = "png256", height = 6, width = 6, res = 72,
               units = "in", pointsize, ..., method = c("postscript", "pdf"))

### Arguments

`file` | The output file name, with an appropriate extension.
`type` | The type of bitmap. the default is `"png256"`.
`width, height` | Dimensions of the display region.
`res` | Resolution, in dots per inch.
`units` | The units in which `height` and `width` are given. Can be `in` (inches), `px` (pixels), `cm` or `mm`.
`pointsize` | The pointsize to be used for text: defaults to something reasonable given the width and height
`...` | Other parameters passed to `postscript` or `pdf`.
`method` | Should the plot be done by `postscript` or `pdf`?

### Details

`dev2bitmap` works by copying the current device to a `postscript` or `pdf` device, and post-processing the output file using `ghostscript`. `bitmap` works in the same way using a `postscript` device and post-processing the output as ‘printing’.

You will need `ghostscript`: the full path to the executable can be set by the environment variable R_GSCMD. (If this is unset the command `"gs"` is used, which will work if it is in your path.)

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

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

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

For graphics parameters such as `"cra"` that need to work in pixels, the default resolution of 72dpi is always used.

### Value

None.

### See Also

`postscript`, `pdf`, `png` and `jpeg` and on Windows `bmp`.

To display an array of data, see `image`.

[Package grDevices version 2.6.0 Index]