Convert IFF.ANY
objects (created with interpretIFFChunk()
) into
IFFChunk()
objects. A basic IFFChunk()
can also be
created with this method by providing the chunk type name.
Usage
IFFChunk(x, ...)
# S3 method for character
IFFChunk(x, ...)
# S3 method for IFF.FORM
IFFChunk(x, ...)
# S3 method for IFF.BODY
IFFChunk(x, ...)
# S3 method for IFF.ANNO
IFFChunk(x, ...)
# S3 method for IFF.AUTH
IFFChunk(x, ...)
# S3 method for IFF.CHRS
IFFChunk(x, ...)
# S3 method for IFF.NAME
IFFChunk(x, ...)
# S3 method for IFF.TEXT
IFFChunk(x, ...)
# S3 method for IFF.copyright
IFFChunk(x, ...)
# S3 method for IFF.CHAN
IFFChunk(x, ...)
# S3 method for IFF.VHDR
IFFChunk(x, ...)
# S3 method for IFF.8SVX
IFFChunk(x, ...)
# S3 method for IFF.ILBM
IFFChunk(x, ...)
# S3 method for IFF.CMAP
IFFChunk(x, ...)
# S3 method for IFF.BMHD
IFFChunk(x, ...)
# S3 method for IFF.CAMG
IFFChunk(x, ...)
# S3 method for IFF.CRNG
IFFChunk(x, ...)
# S3 method for IFF.ANIM
IFFChunk(x, ...)
# S3 method for IFF.ANHD
IFFChunk(x, ...)
# S3 method for IFF.DLTA
IFFChunk(x, ...)
# S3 method for IFF.DPAN
IFFChunk(x, ...)
Arguments
- x
An S3 class
IFF.ANY
object that needs to be coerced into anIFFChunk-class()
object.IFF.ANY
objects are created with theinterpretIFFChunk()
method.x
can also be acharacter
string of a IFF chunk type (e.g., "FORM
" or "BMHD
"). In that case anIFFChunk()
object of that type is created with some basic content.- ...
Arguments passed onto methods underlying the interpretation of the specific IFF chunks. Allowed arguments depend on the specific type of IFF chunk that
x
represents.
Value
Returns an IFFChunk-class()
representation of x
.
Details
IFF data is stored in a IFFChunk-class()
object when read from an
IFF file (read.iff()
). These objects reflect the file structure
well, but the data is stored as raw
information. IFF files can contain
a wide variety of information types, ranging from bitmap images to audio
clips. The raw information stored in IFFChunk()
objects can
be interpreted into more meaningful representations that can be handled in
R. This is achieved with the interpretIFFChunk()
method, which
returns IFF.ANY
objects.
These IFF.ANY
objects are a less strict representation of the
IFF Chunk, but are easier to handle in R. The interpretation method is lossy
and may not preserve all information in the IFF.ANY
object.
The IFFChunk-method()
can coerce IFF.ANY
back
to the more strictly defined IFFChunk-class()
objects.
Be careful with conversions between IFFChunk-class()
and
IFF.ANY
objects and vice versa, as information may get lost.
More detailed information about IFF chunks can be found in the IFF chunk registry (see references).
IFF.FORM
represents a FORM chunk, which is a container that can hold any kind of chunk. When interpreted, it is represented as alist
, where each element is an interpreted chunk nested inside the FORM.IFF.BODY
represents the actual data in an IFF file. However, without context this chunk cannot be interpreted and is therefore interpreted as a vector ofraw
data.IFF.ANIM
represents an animation (ANIM) chunk. When interpreted, it will return alist
where each element is an animation frame represented as anIFF.ILBM
object. Each animation frame should be nested inside an ILBM chunk nested inside a FORM chunk, nested inside an ANIM chunk.IFF.ANHD
represents an ANimation HeaDer (ANHD) chunk. When interpreted, it returns a namedlist
containing the following information:operation
is acharacter
string indicating how the bitmap data for the animation frame is encoded. Can be one of the following: "standard
", "XOR
", "LongDeltaMode
", "ShortDeltaMode
", "GeneralDeltamode
", "ByteVerticalCompression
", "StereoOp5
", or "ShortLongVerticalDeltaMode
". Currently, only the ByteVerticalCompression is implemented in this package.mask
is avector
of 8logical
values. It is currently ignored.w
andh
are positivenumeric
values, specifying the width and height of the frame (should be identical for all frames).x
andy
arenumeric
values, specifying the plotting position for the frame.abstime
is a positivenumeric
value - currently unused - used for timing the frame relative to the time the first frame was displayed. In jiffies (1/60 sec).reltime
is a positivenumeric
value for timing the frame relative to time previous frame was displayed. In jiffies (1/60 sec).interleave
is currently unused. It should be set to 0.pad0
is a padding byte (raw
) for future use.flags
is avector
of 32logical
values. They contain information on how the bitmap data is stored.pad1
are 16 padding bytes (raw
) for future use.
IFF.DPAN
represents an DPaint ANimation (DPAN) chunk. Some software will require this chunk to correctly derive the total number of frames in the animation. When interpreted, it will return a namedlist
with the following elements:version
anumeric
version number.nframes
a positivenumeric
value, indicating the number of frames in the animation.flags
avector
of 32logical
values. Ignored in this package as it was intended for future implementations.
IFF.DLTA
represents a delta mode data chunk (DLTA). The first animation frame is stored as a normal InterLeaved BitMap (ILBM) image as described below. The following frames only store differences in bitmap data compared to the previous frames but is not interleaved. They are thus incorrectly embedded in an ILBM chunk (but is kept so for backward compatibility). When interpreted, agrDevices
raster object is returned only showing the differences. It is not very meaningful to interpret these chunks on their own, but rather the entire parent ANIM chunk.
IFF.ILBM
represents InterLeaved BitMap (ILBM) chunks. It is interpreted here as a raster image (seegrDevices::as.raster()
). ILBM chunks are usually nested inside a FORM container.IFF.BMHD
represents the header chunk of a bitmap (BMHD), and should always be present (nested inside) an ILBM chunk. It is interpreted as a named list containing the following elements:w
andh
are positivenumeric
values specifying the bitmap width and height in pixels. Note that the width can be any positive whole number, whereas the bitmap data always has a width divisible by 16.x
andy
arenumeric
values specifying the plotting position relative to the top left position of the screen. Although required in the bitmap header. It is ignored in the interpretation of bitmap images.nPlanes
is a positive value indicating the number of bitplanes in the image. The number of colours in an image can be calculated as2^nPlanes
.Masking
indicates whether there are bitplanes that should be masked (i.e. are treated as transparent). It is acharacter
string equalling any of the following: "mskNone
", "mskHasMask
", "mskHasTransparentColour
", "mskLasso
" or "mskUnknown
". Only the first (no transparency) and third (one of the colours should be treated as transparent) id is currently interpreted correctly. The others are ignored. "mskUnknown
" means that an undocumented mask is applied to the image.Compression
indicates whether the bitmap data is compressed. It is acharacter
string that can equal any of the following: "cmpNone
", "cmpByteRun1
" or "cmpUnknown
". The latter means an undocumented form of compression is applied and is currently ignored. In most cases bitmap data is compressed with thecmpByteRun1
algorithm (packBitmap()
). In some cases, bitmap data is not compressed (cmpNone
).pad
is araw
byte that is only used to align data. It is ignored in the interpretation.transparentColour
is anumeric
value that indicates which colour number in the palette should be treated as fully transparent (whenMasking
equals "mskHasTransparentColour
").xAspect
andyAspect
or positivenumeric
values that indicate the aspect ratio of the pixels in the image. Amiga screen modes allowed for some extreme pixel aspect ratios. These values are used to stretch the image to their intended display mode.pageWidth
andpageHeight
are positivenumeric
values indicating the size of the screen in which the image should be displayed. They are ignored in the interpretation of the image.
IFF.CMAP
represents the colour map (CMAP) or palette of a bitmap image. Although common, the chunk is optional and can be omitted from the parent ILBM chunk. It is interpreted as a vector of colours (i.e., acharacter
string formatted as '#RRGGBB' or named colours such as 'blue').IFF.CAMG
represents a chunk with information with respect to the display mode in which the bitmap image should be displayed. This information can be used to determine the correct pixel aspect ratio, or is sometimes required to correctly interpret the bitmap information. TheIFF.CAMG
chunk is interpreted as a named list containing the following elements:monitor
: afactor
indicating the hardware monitor on which the image was created and should be displayed (seeamiga_monitors()
).display.mode
: afactor
indicating the display mode in which the image should be displayed (seeamiga_display_modes()
).
IFF.CRNG
is an optional chunk nested in an ILBM chunk. It represents a `colour range' and is used to cycle through colours in the bitmap's palette in order to achieve animation effects. It is interpreted as a named list with the following elements. This chunk is currently not used with the interpretation of ILBM images.padding
are tworaw
padding bytes and are ignored when interpreted.rate
is anumeric
value specifying the rate at which the colours are cycled. The rate is in steps per second.flags
is a flag that indicates how colours should be cycled. It is acharacter
string that can equal any of the following: "RNG_OFF
", "RNG_ACTIVE
", "RNG_REVERSE
" or "RNG_UNKNOWN
". When equal to the first, colours are not cycled. When equal to the second, colours are cycled. When equal to the third, colours are cycled in reverse direction. When equal to the latter, an undocumented form of cycling is applied.low
andhigh
arenumeric
indices of colours between which should be cycled. Only colour from indexlow
up to indexhigh
are affected.
IFF.8SVX
represents 8-bit sampled voice chunks (8SVX). The original Amiga supported 8-bit audio which could be stored using the IFF. 8SVX chunks can contain separate audio samples for each octave. 8SVX chunks are usually stored inside a FORM container. Its body chunk contains 8-bit PCM wave data that could be compressed. When the 8SVX chunk is interpreted with this package, alist
is returned where each element represents an octave given as atuneR::Wave()
object. Possible chunks nested in 8SVX chunks and currently supported by this package are as follows.IFF.VHDR
represents voice header chunks (VHDR). It contains (meta-)information about the audio stored in the body of the parent 8SVX chunk. When interpreted, a namedlist
is returned with the following elements:oneShotHiSamples
is anumeric
value indicating how many samples there are in the audio wave of the first octave in the file, that should not be looped (repeated).repeatHiSamples
is anumeric
value indicating how many samples there are in the audio wave of the first octave in the file, that should be looped (repeated).samplesPerHiCycle
is anumeric
value specifying the number of samples per repeat cycle in the first octave, or 0 when unknown. The number ofrepeatHiSamples
should be an exact multiple ofsamplesPerHiCycle
.samplesPerSec
is anumeric
value specifying the data sampling rate.ctOctave
a positive wholenumeric
value indicating how many octaves are included. In 8SVX files the audio wave is resampled for each octave. The wave data in the body starts with the audio sample in the highest octave (least number of samples). The data is then followed by each subsequent octave, where the number of samples increase by a factor of 2 for each octave.sCompression
is acharacter
string indicating whether and how the wave data in the body is compressed. It can have one of the following values: "sCmpNone
" (no compression), "sCmpFibDelta
" (deltaFibonacciCompress()
ion is applied), "sCmpUnknown
" (an undocumented and unknown form of compression is applied).volume
is a numeric value between0
(minimum) and0x10000
(maximum) playback volume.
IFF.CHAN
represents the channel chunk (CHAN). When interpreted it returns a named list with 1 named element: "channel
". It's value can be one of the followingcharacter
strings "LEFT
", "RIGHT
" or "STEREO
". This indicates for how many (one or two) audio channels data is available in the body of the parent 8SVX chunk. It also indicates two which channels the audio should be played back.
IFF.ANNO
,IFF.AUTH
,IFF.CHRS
,IFF.NAME
,IFF.TEXT
andIFF.copyright
are all unformatted text chunks that can be included optionally in any of the chunk types. Respectively, they represent an annotation, the author's name, a generic character string, the name of the work, generic unformatted text, and copyright text. They are interpreted as acharacter
string.
Examples
if (FALSE) {
## load an IFF file
example.iff <- read.iff(system.file("ilbm8lores.iff", package = "AmigaFFH"))
## interpret the IFF file (in some cases information
## will get lost in this step):
example.itpt <- interpretIFFChunk(example.iff)
## now coerce back to a formal IFFChunk class object.
## Only information in the interpreted object is used
## The coerced object may therefore depart from the
## original read from the file.
example.coerce <- IFFChunk(example.itpt)
## and indeed the objects are not identical, as shown below.
## In this case the difference is not disastrous, the order
## of the colours in the palette have shifted. But be careful
## with switching between formal IFFChunk objects and
## interpreted IFF.ANY objects.
identical(example.iff, example.coerce)
## It is also possible to create simple IFFChunk objects
## by providing the desired chunk type identifier as a
## character string.
## This creates a basic bitmap header:
bmhd <- IFFChunk("BMHD")
## This creates a basic colour palette:
cmap <- IFFChunk("CMAP")
}