Author Topic: ShowPicture Saving Ham Images  (Read 60 times)


  • Newbie
  • *
  • Posts: 40
  • Karma: +2/-1
ShowPicture Saving Ham Images
« on: June 01, 2019, 03:50:36 AM »
After a full year of constant development my Graphics program called ShowPicture is nearly ready for it's first release. It is capable of Loading, Displaying, Converting, Saving many Standard Picture Types such as PNG, BMP, JPG, TGA, etc. It can also save ILBM Bitmap Images of 8 bitplanes and below as well as ILBM Deep Images of 24 bitplanes. Now it can also save 24bit RGB pixel data directly as HAM6 or HAM8 images! There are also many new features on the menu.

Future versions will include Color Quantizing, Color Statistics using HSL, Histograms & Clustering, Color Group Operations, as well as the use of Opacity Masks and Overlay Masks. It can already convert many Bit Depths and Color Quantizing will allow converting from 32bit and 24bit to 8bit  and below. It will also have a menu system for loading, displaying and modifying PNG icon files and also Amiga IFF icon files. It has been an exciting journey so far programming ShowPicture.

The program itself will function as a graphics framework for many different graphics effects and hopefully it will serve as a prototype for future graphics programs. ShowPicture is been developed for Icaros Desktop ABIv0 (version 2.2.5). It is being tested on Icaros Hosted on Windows and Hosted on Linux and Icaros Native.


  • Newbie
  • *
  • Posts: 40
  • Karma: +2/-1
Re: ShowPicture Saving Ham Images
« Reply #1 on: June 01, 2019, 04:09:28 AM »
The sample pcx image has an odd size of 474 x 329. In order to save HAM6 & HAM8 images the scanline length must be modulus 16 (evenly divisible by 16). Padding bytes are added at the end of each scanline to make it the correct length so that the bitplanes will be of equal length. I recently got this to work using the following code: 

    //Check if image width is modulus 16.
    int alignedwidth = (Ham_Width + 15) & ~15;
    "bytesPerLine = (alignedwidth / 8 );"
    //UBYTE chunkyBuffer[(HamDepth * bytesPerLine)]; //Causes Save Ham6 to Crash!
    //UBYTE chunkyBuffer[Ham_Width];
    UBYTE chunkyBuffer[alignedwidth];

The HAM save function wasn't working correctly for HAM6 images until I set the size of chunkyBuffer to alignedwidth which is modulus 16. The chunkyBuffer is used to hold all the hambytes before chunky bytes are converted to planar data before writing to the HAM ILBM file. The function also saves RGB data as HAM8. The C2P conversion that I used was adapted from one of my C# ILBM Viewers. It allows converting from 8 bitplanes to any number of lesser values such as 6 bitplanes for saving HAM6. This process can also be used to convert an 8bit standard image to an ILBM bitmap image of 5 bitplanes for use in Amiga IFF icons.

ChunkyBufferToBitplanes(UBYTE *chunkyBuffer, UBYTE *bitBuffer, int bitPlanes, int imagewidth)
    //Convert one scanline from chunky to planar.
    int i, j;
    int hOffset = 0;
    int bitplaneIndex = 0;
    //int bit = 0;
    "int bytesPerLine = (imagewidth / 8 );"
    int rowSize = (bitPlanes * bytesPerLine);

    //Block of 8 colors
    UBYTE colorBytes[8];

    //EasyRequest(NULL, &ResultReq, NULL, "ChunkyPixelsToBitplanes");
    while (hOffset < bytesPerLine)
        //Copy 8 colorBytes to new buffer. Chunky Buffer is Modulus 16 & therefore Modulus 8.
        "memcpy(colorBytes, chunkyBuffer + (hOffset * 8 ), 8 );"
        for (j = 0; j < bitPlanes; j++) //Fill bitplane byte locations (Up to bytesPerLine)
            bitplaneIndex = (j * bytesPerLine);
            //UBYTE bitmask = (UBYTE)(1 << bit);
            //Set corresponding bits in bitplane buffers.
            for (i = 0; i < 8; i++)
                /* Check if the current bit of the index value is set */
                if ((colorBytes & (1 << j)) != 0)
                    //("Bit is Set (1).")
                    /* Modify the current bit in the bitplane byte to be 1 and leave the others untouched */
                    bitBuffer[bitplaneIndex + hOffset] |= (UBYTE)(1 << 7 - i);
                    //Set bit = number |= 1 << x; //return value |= (UBYTE)(1 << pos);
                    //("Bit is Not Set (0). ")
                    /* Modify the current bit in the bitplane byte to be 0 and leave the others untouched */
                    bitBuffer[bitplaneIndex + hOffset] &= (UBYTE)(~(1 << 7 - i));
                    //Clear bit = number &= ~(1 << x); //return value &= (UBYTE)(~(1 << pos));


    }//End while loop

« Last Edit: June 01, 2019, 04:13:22 AM by miker1264 »


  • Senior Member
  • ****
  • Posts: 265
  • Karma: +2/-0
  • healt problem, In the Past Was a Little Musician
    • My Personal Web Page
Re: ShowPicture Saving Ham Images
« Reply #2 on: June 01, 2019, 03:14:46 PM »
thank yo very much is great
Icaros Desktop on Fujistu Esprimo Intel Core 2 Duo 3 Ghz