Amiga images are usually stored as bitmap images with indexed colours. This
function converts raw Amiga bitmap data into raster data
1 2 3 4 5 6 7 8
Width in pixels of the bitmap image. Can be any positive value. However, bitmap data is ‘word’ aligned on the amiga. This means that the width of the stored bitmap data is a multiple of 16 pixels. The image is cropped to the width specified here.
Height in pixels of the bitmap image.
The colour depth of the bitmap image (i.e., the number of bit planes).
The image will be composed of
Bitmap images stored as raw data, representing palette index colours, can
be converted into raster data (
as.raster). The latter
data can easily be plotted in R. It is usually not necessary to call this function
directly, as there are several more convenient wrappers for this function. Those
wrappers can convert specific file formats (such as IFF ILBM and Hardware Sprites,
as.raster) into raster objects. This function is
provided for completeness sake (or for when you want to search for images in an
amiga memory dump).
Returns a raster object (
as.raster) as specified in
grDevices package. Unless,
palette is set to
in which case a
numeric palette index values is returned.
Pepijn de Vries
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
## Not run: ## first load an example image: example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH")) ## get the raw bitmap data, which is nested in the InterLeaved BitMap (ILBM) ## IFF chunk as the BODY: bitmap.data <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "BODY"))) ## In order to translate the bitmap data into a raster object we need ## to know the image dimensions (width, height and colour depth). This ## information can be obtained from the bitmap header (BMHD): bitmap.header <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "BMHD"))) ## First the bitmap data needs to be unpacked as it was stored in a compresssed ## form in the IFF file (see bitmap.header$Compression): bitmap.data <- unPackBitmap(bitmap.data) ## It would also be nice to use the correct colour palette. This can be obtained ## from the CMAP chunk in the IFF file: bitmap.palette <- interpretIFFChunk(getIFFChunk(example.iff, c("ILBM", "CMAP"))) example.raster <- bitmapToRaster(bitmap.data, bitmap.header$w, bitmap.header$h, bitmap.header$nPlanes, bitmap.palette) ## We now have a raster object that can be plotted: plot(example.raster, interpolate = FALSE) ## End(Not run)
Loading required package: tuneR
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.