Datatype Color Quantizing

miker1264 · 4332

miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #45 on: December 09, 2021, 11:38:35 AM
Here is the compiled AROS 68k version. Just copy it to the C directory and have fun making iLBM's.

Input-File is any image supported by datatypes I assume

Thanks Miker

Yes. Input for pic2iff can be any supported picture file.

It's similar to dt2gif. If the source is 8bit it copies from old datatype to new datatype and saves to iff file. If the source is 24bit or 32bit it quantizes to 8bit and saves to iff file.

It works great for larger images. But for 32bit icon images I must work out how to use bmhd transparent color for the converted alpha values. Currently it leaves a black ring around the image where the alpha values were. I have to work that out.




miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #46 on: December 09, 2021, 11:48:05 AM

[/quote]

hi Mike
While you are taking over to your png2icom program can you please review your icon2iff as well to correct the issue on converting icons with only one icon status.
Thanks
[/quote]

@ilBarbax

I'm currently revising "icon2png". It was written so long ago. Looking back much of it is well conceived and well written but other parts need work. I'm reorganizing it into new functions including checking the png icon for one or two images.

If it only has one png image I will do what Icon Library does. Duplicate the first image to make a second image. We have two choices - washout the second image making it much lighter. Or the more difficult but better option would be to darken the second image using contrast/brightness then add glow border.

I hope to reuse this code in ConvertIcon so it's worth the effort.




miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #47 on: December 09, 2021, 04:02:22 PM
For PIC2IFF I resolved the transparency issue.

When converting 32bit PNG Icon Images to 8bit ILBM there is a loss of alpha values.

To compensate for that the BMHD for AROS ILBM images uses a Transparent Color.

After we get the index values from Neuquant using "inxsearch" such as...

/* Convert 32bit pixels to indexes */      
        for (x = 0; x < Size; ++x)
        {               
            buffer(x) =inxsearch(pixelBuffer[(x*4)+3], //b
              pixelBuffer[(x*4)+2], //g
              pixelBuffer[(x*4)+1], //r
              pixelBuffer[x*4]); //a               
        }

Then we get the colormap index of the first background color which is assigned in BMHD as Transparent.

//Get colormap index of first color.
       BYTE map_idx = buffer[0];

After that it is simple comparison between the original color's alpha value. If less than 255 assign the map_idx. (Transparent Color).

See results in screenshot. We now have a "Transparent IFF Image" that can be used to make an IFF Icon (OS35 Glow Icon Format).

« Last Edit: December 09, 2021, 05:16:10 PM by miker1264 »