getIFFChunk: Get a specific IFFChunk nested inside other IFFChunks

getIFFChunkR Documentation

Get a specific IFFChunk nested inside other IFFChunks

Description

IFFChunk()s can be nested in a tree-like structure. Use this method to get a specific chunk with a specific label.

Usage

## S4 method for signature 'IFFChunk,character,integer'
getIFFChunk(x, chunk.path, chunk.number)

## S4 method for signature 'IFFChunk,character,missing'
getIFFChunk(x, chunk.path, chunk.number)

## S4 replacement method for signature 'IFFChunk,character,missing,IFFChunk'
getIFFChunk(x, chunk.path, chunk.number = NULL) <- value

## S4 replacement method for signature 'IFFChunk,character,integer,IFFChunk'
getIFFChunk(x, chunk.path, chunk.number = NULL) <- value

Arguments

x

An IFFChunk() object from which the nested IFFChunk() should be extracted an returned.

chunk.path

A vector of 4 character long strings of IFF chunk labels, specifying the path of the target IFF chunk. For example: c("ILBM", "BODY") means, get the "BODY" chunk from inside the "ILBM" chunk.

chunk.number

A vector of the same length as chunk.path, with integer index numbers. Sometimes a chunk can contain a list of chunks with the same label. With this argument you can specify which element should be returned. By default (when missing), the first element is always returned.

value

An IFFChunk() with which the target chunk should be replaced. Make sure that value is of the same chunk.type as the last chunk specified in the chunk.path.

Details

IFFChunk objects have 4 character identifiers, indicating what type of chunk you are dealing with. These chunks can be nested inside of each other. Use this method to extract specific chunks by referring to there respective identifiers. The identifiers are shown when calling print on an IFFChunk(). If a specified path doesn't exist, this method throws a ‘subscript out of range’ error.

Value

Returns an IFFChunk() object nested inside x at the specified path. Or in case of the replace method the original chunk x is returned with the target chunk replaced by value.

Author(s)

Pepijn de Vries

See Also

Other iff.operations: IFFChunk-class, WaveToIFF(), as.raster.AmigaBasicShape(), interpretIFFChunk(), rasterToIFF(), rawToIFFChunk(), read.iff(), write.iff()

Examples

## Not run: 
## load an IFF file
example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH"))

## Get the BMHD (bitmap header) from the ILBM (interleaved bitmap) chunk:
bmhd <- getIFFChunk(example.iff, c("ILBM", "BMHD"))

## This is essentially doing the same thing, but we now explicitly
## tell the method to get the first element for each specified label:
bmhd <- getIFFChunk(example.iff, c("ILBM", "BMHD"), c(1L, 1L))

## Let's modify the bitmap header and replace it in the parent IFF chunk.
bmhd.itpt <- interpretIFFChunk(bmhd)

## Let's disable the masking, the bitmap will no longer be transparent:
bmhd.itpt$Masking <- "mskNone"
bmhd <- IFFChunk(bmhd.itpt)

## Now replace the header from the original iff with the modified header:
getIFFChunk(example.iff, c("ILBM", "BMHD")) <- bmhd

## End(Not run)

AmigaFFH documentation built on June 22, 2024, 11:03 a.m.