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 class 'character'
IFFChunk(x, ...)
# S3 method for class 'IFF.FORM'
IFFChunk(x, ...)
# S3 method for class 'IFF.BODY'
IFFChunk(x, ...)
# S3 method for class 'IFF.ANNO'
IFFChunk(x, ...)
# S3 method for class 'IFF.AUTH'
IFFChunk(x, ...)
# S3 method for class 'IFF.CHRS'
IFFChunk(x, ...)
# S3 method for class 'IFF.NAME'
IFFChunk(x, ...)
# S3 method for class 'IFF.TEXT'
IFFChunk(x, ...)
# S3 method for class 'IFF.copyright'
IFFChunk(x, ...)
# S3 method for class 'IFF.CHAN'
IFFChunk(x, ...)
# S3 method for class 'IFF.VHDR'
IFFChunk(x, ...)
# S3 method for class 'IFF.8SVX'
IFFChunk(x, ...)
# S3 method for class 'IFF.ILBM'
IFFChunk(x, ...)
# S3 method for class 'IFF.CMAP'
IFFChunk(x, ...)
# S3 method for class 'IFF.BMHD'
IFFChunk(x, ...)
# S3 method for class 'IFF.CAMG'
IFFChunk(x, ...)
# S3 method for class 'IFF.CRNG'
IFFChunk(x, ...)
# S3 method for class 'IFF.ANIM'
IFFChunk(x, ...)
# S3 method for class 'IFF.ANHD'
IFFChunk(x, ...)
# S3 method for class 'IFF.DLTA'
IFFChunk(x, ...)
# S3 method for class 'IFF.DPAN'
IFFChunk(x, ...)Arguments
- x
An S3 class
IFF.ANYobject that needs to be coerced into anIFFChunk-class()object.IFF.ANYobjects are created with theinterpretIFFChunk()method.xcan also be acharacterstring 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
xrepresents.
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.FORMrepresents 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.BODYrepresents the actual data in an IFF file. However, without context this chunk cannot be interpreted and is therefore interpreted as a vector ofrawdata.IFF.ANIMrepresents an animation (ANIM) chunk. When interpreted, it will return alistwhere each element is an animation frame represented as anIFF.ILBMobject. Each animation frame should be nested inside an ILBM chunk nested inside a FORM chunk, nested inside an ANIM chunk.IFF.ANHDrepresents an ANimation HeaDer (ANHD) chunk. When interpreted, it returns a namedlistcontaining the following information:operationis acharacterstring 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.maskis avectorof 8logicalvalues. It is currently ignored.wandhare positivenumericvalues, specifying the width and height of the frame (should be identical for all frames).xandyarenumericvalues, specifying the plotting position for the frame.abstimeis a positivenumericvalue - currently unused - used for timing the frame relative to the time the first frame was displayed. In jiffies (1/60 sec).reltimeis a positivenumericvalue for timing the frame relative to time previous frame was displayed. In jiffies (1/60 sec).interleaveis currently unused. It should be set to 0.pad0is a padding byte (raw) for future use.flagsis avectorof 32logicalvalues. They contain information on how the bitmap data is stored.pad1are 16 padding bytes (raw) for future use.
IFF.DPANrepresents 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 namedlistwith the following elements:versionanumericversion number.nframesa positivenumericvalue, indicating the number of frames in the animation.flagsavectorof 32logicalvalues. Ignored in this package as it was intended for future implementations.
IFF.DLTArepresents 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, agrDevicesraster 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.ILBMrepresents 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.BMHDrepresents 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:wandhare positivenumericvalues 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.xandyarenumericvalues 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.nPlanesis a positive value indicating the number of bitplanes in the image. The number of colours in an image can be calculated as2^nPlanes.Maskingindicates whether there are bitplanes that should be masked (i.e. are treated as transparent). It is acharacterstring 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.Compressionindicates whether the bitmap data is compressed. It is acharacterstring 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 thecmpByteRun1algorithm (packBitmap()). In some cases, bitmap data is not compressed (cmpNone).padis arawbyte that is only used to align data. It is ignored in the interpretation.transparentColouris anumericvalue that indicates which colour number in the palette should be treated as fully transparent (whenMaskingequals "mskHasTransparentColour").xAspectandyAspector positivenumericvalues 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.pageWidthandpageHeightare positivenumericvalues indicating the size of the screen in which the image should be displayed. They are ignored in the interpretation of the image.
IFF.CMAPrepresents 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., acharacterstring formatted as '#RRGGBB' or named colours such as 'blue').IFF.CAMGrepresents 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.CAMGchunk is interpreted as a named list containing the following elements:monitor: afactorindicating the hardware monitor on which the image was created and should be displayed (seeamiga_monitors()).display.mode: afactorindicating the display mode in which the image should be displayed (seeamiga_display_modes()).
IFF.CRNGis 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.paddingare tworawpadding bytes and are ignored when interpreted.rateis anumericvalue specifying the rate at which the colours are cycled. The rate is in steps per second.flagsis a flag that indicates how colours should be cycled. It is acharacterstring 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.lowandhigharenumericindices of colours between which should be cycled. Only colour from indexlowup to indexhighare affected.
IFF.8SVXrepresents 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, alistis 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.VHDRrepresents voice header chunks (VHDR). It contains (meta-)information about the audio stored in the body of the parent 8SVX chunk. When interpreted, a namedlistis returned with the following elements:oneShotHiSamplesis anumericvalue indicating how many samples there are in the audio wave of the first octave in the file, that should not be looped (repeated).repeatHiSamplesis anumericvalue indicating how many samples there are in the audio wave of the first octave in the file, that should be looped (repeated).samplesPerHiCycleis anumericvalue specifying the number of samples per repeat cycle in the first octave, or 0 when unknown. The number ofrepeatHiSamplesshould be an exact multiple ofsamplesPerHiCycle.samplesPerSecis anumericvalue specifying the data sampling rate.ctOctavea positive wholenumericvalue 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.sCompressionis acharacterstring 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).volumeis a numeric value between0(minimum) and0x10000(maximum) playback volume.
IFF.CHANrepresents the channel chunk (CHAN). When interpreted it returns a named list with 1 named element: "channel". It's value can be one of the followingcharacterstrings "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.TEXTandIFF.copyrightare 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 acharacterstring.
Examples
## 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)
#> [1] FALSE
## 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")