colourToAmigaRaw: Convert colours to Amiga compatible raw data or vice versa

View source: R/generic_support.r

colourToAmigaRawR Documentation

Convert colours to Amiga compatible raw data or vice versa

Description

Convert colours to Amiga compatible raw data or vice versa, such that it can be used in graphical objects from the Commodore Amiga.

Usage

colourToAmigaRaw(
  x,
  colour.depth = c("12 bit", "24 bit"),
  n.bytes = c("2", "3")
)

amigaRawToColour(
  x,
  colour.depth = c("12 bit", "24 bit"),
  n.bytes = c("2", "3")
)

Arguments

x

In the case amigaRawToColour is called, x should be a vector of raw data. The length of this vector should be a multiple of 2 (when n.bytes = "2") or 3 (when n.bytes = "3"). When colourToAmigaRaw is called, x should be a character strings representing a colour.

colour.depth

A character string: "12 bit" (default) or "24 bit". The first should be used in most cases, as old Amigas have a 12 bit colour depth.

n.bytes

A character string: "2" or "3". The number of bytes that is used or should be used to store each colour.

Details

On the original Commodore Amiga chipset, graphics used indexed palettes of 12 bit colours. Colours are specified by their RGB (Red, Green and Blue) values, each component requiring 4 bits (with corresponding values ranging from 0 up to 15). Data structures on the Amiga were WORD (2 bytes) aligned. Colours are therefore typically stored in either 2 bytes (skipping the first four bits) or 3 bytes (one byte for each value).

These functions can be used to convert R colours into the closest matching Amiga colour in a raw format, or vice versa. Note that later Amiga models with the advanced (graphics) architecture (known as AA or AGA) allowed for 24 bit colours.

Value

In the case amigaRawToColour is called, a (vector of) colour character string(s) is returned. When colourToAmigaRaw is called, raw representing the colour(s) specified in x is returned.

Author(s)

Pepijn de Vries

See Also

Other raw.operations: as.AmigaBasic(), as.raw.AmigaBasic(), packBitmap(), rawToAmigaBasicBMAP(), rawToAmigaBasicShape(), rawToAmigaBasic(), rawToAmigaBitmapFontSet(), rawToAmigaBitmapFont(), rawToAmigaIcon(), rawToHWSprite(), rawToIFFChunk(), rawToSysConfig(), simpleAmigaIcon()

Examples

## Let's create some Amiga palettes:
colourToAmigaRaw(c("red", "navy blue", "brown", "#34AC5A"))

## let's do the reverse.
## this is white:
amigaRawToColour(as.raw(c(0x0f, 0xff)))

## this is white specified in 3 bytes:
amigaRawToColour(as.raw(c(0xf0, 0xf0, 0xf0)), n.bytes = "3")

## lower nybbles are ignored, you will get a warning when it is not zero:
amigaRawToColour(as.raw(c(0xf0, 0xf0, 0x0f)), n.bytes = "3")

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