if (FALSE) {
## first: Let's make a raster out of the 'volcano' data, which we can use in the example:
volcano.raster <- as.raster(t(matrix(terrain.colors(1 + diff(range(volcano)))[volcano -
min(volcano) + 1], nrow(volcano))))
## Turning the raster into an IFFChunk object is easy:
volcano.iff <- rasterToIFF(volcano.raster)
## This object can be saved as an IFF file using write.iff
## in special modes HAM6 and HAM 8 higher quality images
## can be obtained. See 'rasterToBitmap' for more info on the
## special HAM modes.
volcano.ham <- rasterToIFF(volcano.raster, "HAM_KEY", depth = "HAM8")
## The result can be further improved by applying dithering
volcano.ham.dither <- rasterToIFF(volcano.raster, "HAM_KEY", depth = "HAM8",
indexing = function(x, length.out) {
index.colours(x, length.out, dither = "JJN", iter.max = 20)
})
}
Run the code above in your browser using DataLab