## 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)
Run the code above in your browser using DataLab