English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. General (http://eab.abime.net/forumdisplay.php?f=37)
-   -   ham howto? (http://eab.abime.net/showthread.php?t=83279)

billt 29 June 2016 00:31

ham howto?
Hi all,

I'm hoping to use HAM as a topic for a presentation on the Image Engineering course I'm taking at university. Are there good resources and examples on how to parse a HAM image file, and how it works wih te classic hardware, and how we might parse and render to modern 24bit display?

hooverphonique 29 June 2016 11:10

You mean an IFF ILBM file? it's just stored as interleaved bitplanes, so read up on how ham mode works, and you will know how to interpret the data.

meynaf 29 June 2016 12:48

Perhaps you can start by displaying a normal amiga planar image. If you can do that, ham will be easy to add.

Thorham 29 June 2016 15:05


Originally Posted by billt (Post 1098695)
how it works with the classic hardware

HAM is quite simple. Pixels are either 6 (HAM6) or 8 (HAM8) bits. Each HAM pixel has two mode bits and 4 or 6 color bits. In this diagram, the m bits are mode bits, and the c bits are color bits:

Bit nr:    5  4  3  2  1  0
Function: c3 c2 c1 c0 m1 m0

Bit nr:    7  6  5  4  3  2  1  0
Function: m1 m0 c5 c4 c3 c2 c1 c0

In addition to that, HAM modes also have a palette. For HAM6 it's 16 colors, and for HAM8 it's 64 colors.

The function of the mode bits is as follows:


00 = Color of the pixel is taken from the palette, with the color bits being
    the index.

01 = Take visible RGB value of the pixel to the left, and set the blue
    component to the value of the color bits of the current pixel.

10 = Take visible RGB value of the pixel to the left, and set the red
    component to the value of the color bits of the current pixel.

11 = Take visible RGB value of the pixel to the left, and set the green
    component to the value of the color bits of the current pixel.

Basically, if red, green or blue is set, the pixel gets the value of the pixel to the left with one of the components changed to a new value.

For the left most pixel on a line, the RGB value for the missing pixel to the left if black, if I'm not mistaken.

That's it.


Originally Posted by billt (Post 1098695)
and how we might parse and render to modern 24bit display?

With the explanation above it should be trivial to implement this.

thellier 29 June 2016 15:50

see my prog & sources:


About how to generate an IFF-Ham image from an RGB picture
Also contain code for reducing an RGB picture & Floyd Steinberg


billt 29 June 2016 19:07

Thank you for the technical info, Alain! perhaps Ive had some misunderstanding of all that, as I was thinking that HAM and SHAM were image formats, including the palette table(s) within the IFF image contianer. Is that so, or is HAM really only a display mode on which to paint an image file to screen, and the file does not know anything about HAM palette or presence?

So, to display an image to HAM display, is there a related file format, or is there an iff "generic" image format with enough colors to require/makes use of HAM mode (or jpeg etc), with the viewer program being responsible for converting a "generic image" data, analyzing the image and choosing the palette table colors, processing into "HAM pixel format" and then pushing the analyzed result onto the HAM hardware?

If I misunderstood, and it's really up to the viewer program to put an image of whatever format onto a HAM display, then I think that's still an interesting topic for this course presentation, I just need to adjust a bit.

mark_k 29 June 2016 19:15

HAM images are typically stored as IFF-ILBM files, with six bitplanes of image data and a CAMG chunk telling the reader that it's a HAM image.

An Amiga image display program would open a HAM-mode custom screen, set its palette to that given in the image file (CMAP chunk), then copy or decompress the image data to the screen's bitmap.

meynaf 29 June 2016 19:19

HAM is really just a display mode.

Most image formats don't know about it ; IFF files can contain a CAMG chunk indicating the HAM mode.

When the image doesn't tell a thing (the usual case) it's really up to the viewer program to convert an image onto a HAM display, and this is exactly how 24-bit images are shown on the Amiga.
I know, i've written such a program ;)

Akira 29 June 2016 19:24

Sorry to butt in and go a bit off topic.

If you open a HAM image in a non-HAM screen, how will it look? Has anybody done an application that does this? (like opening a HAM image on a graphic card screen)
I am guessing all the color artifaction disappears?

meynaf 29 June 2016 19:28

Get an IFF HAM image, then use a hex editor and trash the CAMG chunk (changing the "C" into "D" is enough). You can then see by yourself.
The result is awful, like changing the colors of ~80% pixels into random.

flype 30 June 2016 09:59

Maybe you can have a look at a code i made some months ago. It is not perfect and for a specific language (PureBasic for Windows) but it gives you the math and logic to parse IFF file and HAM pixelformat to modern display. I have also somewhere a C equivalent that i never finished, maybe i might search for it deep in my PC hard drive.


billt 04 July 2016 15:46

Thanks everyone!

All times are GMT +2. The time now is 22:50.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.

Page generated in 0.05093 seconds with 11 queries