English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 29 June 2016, 00:31   #1
billt
Registered User
 
Join Date: Sep 2010
Location: Maryland, USA
Posts: 82
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?
billt is offline  
Old 29 June 2016, 11:10   #2
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
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.
hooverphonique is offline  
Old 29 June 2016, 12:48   #3
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Perhaps you can start by displaying a normal amiga planar image. If you can do that, ham will be easy to add.
meynaf is offline  
Old 29 June 2016, 15:05   #4
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
Quote:
Originally Posted by billt View Post
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:
Code:
HAM6:
Bit nr:    5  4  3  2  1  0
Function: c3 c2 c1 c0 m1 m0

HAM8:
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:

Code:
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.

Quote:
Originally Posted by billt View Post
and how we might parse and render to modern 24bit display?
With the explanation above it should be trivial to implement this.
Thorham is offline  
Old 29 June 2016, 15:50   #5
thellier
Registered User
 
Join Date: Sep 2011
Location: Paris/France
Posts: 274
see my prog & sources:

http://aminet.net/package/gfx/conv/DatatypeToHam

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

Alain
thellier is offline  
Old 29 June 2016, 19:07   #6
billt
Registered User
 
Join Date: Sep 2010
Location: Maryland, USA
Posts: 82
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.
billt is offline  
Old 29 June 2016, 19:15   #7
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
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.
mark_k is online now  
Old 29 June 2016, 19:19   #8
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
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
meynaf is offline  
Old 29 June 2016, 19:24   #9
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
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?
Amiga1992 is offline  
Old 29 June 2016, 19:28   #10
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
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.
meynaf is offline  
Old 30 June 2016, 09:59   #11
flype
Registered User
 
Join Date: Dec 2014
Location: France
Posts: 104
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.

http://www.purebasic.fr/english/viewtopic.php?p=471869
flype is offline  
Old 04 July 2016, 15:46   #12
billt
Registered User
 
Join Date: Sep 2010
Location: Maryland, USA
Posts: 82
Thanks everyone!
billt is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
HAM conversion alpine9000 Coders. General 27 04 November 2019 21:51
Ham videos Zooup1972 support.Apps 17 19 April 2015 00:35
Fun with HAM Mequa Amiga scene 10 01 January 2011 05:54
Amiga HAM Si-Pie Amiga scene 12 13 November 2008 23:50
HAM pictures jviper New to Emulation or Amiga scene 2 24 March 2006 01:03

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:11.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14555 seconds with 13 queries