Hold-and-modify mode

from Wikipedia, the free encyclopedia

The Hold-And-Modify-Modus (HAM-Modus) is a display mode of the graphic chipsets of the Amiga platform to display 12- bit and 18-bit pictures with only 6 or 8 bits per pixel . A special hardware-implemented data compression is used to save memory bandwidth.

If there is a CAMG chunk in an IFF image file , this mode can be identified at the 11th bit.

There are two variants of the HAM mode:

  • HAM or HAM6 images can display 4096 colors and use six bits per pixel and a color palette of 16 colors.
  • The HAM8 mode was introduced with the Amiga 4000 and Amiga 1200 and offers a very good, photo-like image quality with only eight bits per pixel and a basic palette of 64 colors. In this mode, almost as many colors from the 24-bit spectrum can be displayed as fit in the chip RAM (minus the first pixel column) and as the image resolution allows.

The color of a pixel in HAM mode can be any color of the 12-bit color palette for HAM6 or the 24-bit color palette for HAM8. Alternatively, the color of the pixel directly to the left can be adopted, whereby one of the three color components of the RGB color space (red, green, blue) is set to a new value. The edge color is adopted on the left side of the image (color index 0 of the color palette). Note: The video hardware does not start with the first pixel of a bitplane , but only with the first visible pixel, which makes an (unattractive) difference in hardware scrolling (virtual or oversized screen).

This process harmonises with the properties of television signals (FBAS) so that the lossy data compression does not lead to a reduction in quality.

In HAM image files, the pixel data is stored in the BODY chunk as a code, which is divided into the mode and the remaining bits. The coding of the pixels corresponds to the format used by the video hardware.

mode meaning
00 Index in the color palette
01 Change in the blue component
10 Change in the red component
11 Change in the green component

If a pixel does not represent a color of the palette (mode 00), only the new value of one of the three RGB values ​​can be specified. The other two values ​​are the same as in the previous pixel. If the pixel is the first of an image line, the previous pixel is assumed to be an RGB triplet (0, 0, 0) (unlike the video hardware, see above).

Format of mode and data bits of a pixel in HAM6 mode:

00wxyz – Farbindex wxyz in eine 16 Einträge lange Basisfarbenpalette
01wxyz – Behalte den Farbwert des vorherigen Pixels, aber setze die (obersten) vier Bit von Blau auf wxyz
10wxyz – Behalte den Farbwert des vorherigen Pixels, aber setze die (obersten) vier Bit von Rot auf wxyz
11wxyz – Behalte den Farbwert des vorherigen Pixels, aber setze die (obersten) vier Bit von Grün auf wxyz

A HAM picture cannot be decoded directly into a picture with 256 or less colors without first performing a color reduction. To get full quality, you need at least a 12-bit image.

If you want to convert an image that is available in 256 or more colors into a HAM image, you first look for the optimal basic palette for this image, with which as many points of the image as possible can be displayed directly or with only minor deviations. Once the basic palette has been determined, one goes through the image line by line and optimizes for each pixel whether it can best be represented by one of the basic palette colors or, even better, by a HAM modification of the preceding pixel (one of the three RGB color components to the desired value put). The evaluation is carried out by calculating the distance in the 3D color space between the image pixel and the respective base or HAM candidate. This is so generally true of both HAM6 and HAM8.

The number of data bits is four for standard HAM6 and six for HAM8. The number of bitplanes in the BMHD chunk is six or eight. If a HAM picture is to be displayed as a 24-bit picture, the data bits (four or six) should be expanded to eight bits. The maximum value should be converted to 255 with eight bits per RGB channel.

Format of mode and data bits of a pixel in HAM8 mode:

00uvwxyz – Farbindex uvwxyz in eine 64 Einträge lange Basisfarbenpalette
01uvwxyz – Behalte den Farbwert des vorherigen Pixels, aber setze die obersten sechs Bit von Blau auf uvwxyz
10uvwxyz – Behalte den Farbwert des vorherigen Pixels, aber setze die obersten sechs Bit von Rot auf uvwxyz
11uvwxyz – Behalte den Farbwert des vorherigen Pixels, aber setze die obersten sechs Bit von Grün auf uvwxyz

HAM8 images must be converted to 24-bit images in order to retain the full image quality on non-Amiga systems.

In order to really be able to display all colors of the 24-bit palette in HAM8 mode, the 64 colors of the basic palette must be pre-assigned so that the 64 possible combinations of the lowest two bits of all color components are precisely covered. Then you can use the HAM mechanism to reach all the colors of the 24-bit palette from these basic colors. The number of colors that can be displayed at the same time is only limited by the size of the chip RAM . The latter is two megabytes, so that you can display around 2 million different colors on a HAM8 picture. (Various other amounts go from the chip RAM for the workbench and various data structures of the operating system that must be in the chip RAM.)


It has long been under discussion to replace this HAM mode, which is based on RGB color representation, with a corresponding mode based on the HSV color space (hue, saturation, lightness), from which one has even higher compression options and / or even more promised better display quality. However, the HAM mode is no longer necessary on current computers due to the lower RAM prices and the faster graphics hardware, so that these considerations have not yet led to a practical implementation .

See also