RISC OS colour format converters


Wimp colour

This format is used with Wimp_SetColour and Wimp_TextColour. The lower 4 bits are used as a palette index. By default, the palette is configured as shown below. Bits 4..6 specify the plotting action (e.g. 'OR', 'XOR' or overwrite) for Wimp_SetColour. Bit 7 controls whether Wimp_SetColour and Wimp_TextColour set a foreground or background colour. The same 16 colours are used with Wimp_SetFontColours and in window, icon and menu definitions. Not all of the standard colours can be accurately displayed in 256 colour screen modes. This convertor uses a weighted least-squares algorithm.

Wimp colour:    
 

Wimp colour format
Bit: 7 6 5 4 3 2 1 0
Meaning: Background Action Action Action Colour Colour Colour Colour
State:
Default Wimp palette
Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Name: White Grey Grey Grey Grey Grey Grey Black Dark blue Yellow Green Red Cream Army green Orange Light blue


Colour number

This format is output by ColourTrans_ReturnColourNumber in 256 colour screen modes with the default palette, for use with OS_SetColour. It is optimised for the video hardware, which uses the lower 4 bits as a palette index but overrides some bits of the palette entry with bits 4..7 of the colour number. By default, the palette is configured as shown below. It cannot radically change colours because it does not affect the most significant bit of any colour component. The peculiar bit assignment explains the order of colours offered by the Paint application.

Colour number:     
 

Colour number format
Bit: 7 6 5 4 3 2 1 0
Meaning: Blue high Green high Green low Red high Blue low Red low Tint high Tint low
State:
Default VIDC palette
Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Name: Black Grey Grey Grey Red Red Red Red Blue Blue Blue Blue Purple Purple Purple Purple


Packed GCOL and TINT

This format is output by ColourTrans_ReturnGCOL in 256 colour screen modes with the default palette. It is designed to be easier to work with than colour numbers: the red, green and blue components are arranged more intuitively. The interpretation of bits 0..2 and 6 still depends on the palette. Packed GCOLs can be converted to colour numbers and vice-versa by bit rearrangement or by using the ColourTrans SWIs.

Packed GCOL:     
 

Packed GCOL format
Bit: 7 6 5 4 3 2 1 0
Meaning: Blue high Blue low Green high Green low Red high Red low Tint high Tint low
State:


Separate GCOL and TINT

This format is used with VDU commands 17 (set text colour) and 18 (set graphics colour) in 256 colour screen modes with the default palette. It is also required by BBC BASIC 's GCOL and COLOUR keywords. The bottom 6 bits are the same as a packed GCOL shifted two binary places right; bit 7 indicates whether to set a foreground or background colour. The tint must be specified separately using VDU command sequence 23,17,0..3 or the TINT keyword.

Separate GCOL:  TINT:   
 

GCOL format
Bit: 7 6 5 4 3 2 1 0
Meaning: Background Unused Blue high Blue low Green high Green low Red high Red low
State:
TINT format
Bit: 7 6 5 4 3 2 1 0
Meaning: Tint high Tint low Unused Unused Unused Unused Unused Unused
State:


HTML colour

This 24 bit hexadecimal format is used to specify colours in HTML attribute values and style sheets. It can represent many more colours than available in a 256 colour screen mode. Each colour component has a resolution of 28 instead of 24 and the least significant bits of the red, green and blue components need not be equal. Conversions from HTML colour to one of the standard 256 colours (or 16 Wimp colours), give only approximate results. This convertor uses a weighted least-squares algorithm.

HTML colour:     
 

HTML colour format
Bit: 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Meaning: Red Red Red Red Red Red Red Red Green Green Green Green Green Green Green Green Blue Blue Blue Blue Blue Blue Blue Blue
State:


While you're in the area, you may also be interested in Star Fighter 3000 or the Guild of Spacing.