icon splitter

magorium · 8469

magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #45 on: March 13, 2023, 02:20:44 AM
Hi Miker,

Thank you for your progress reports and attachments.

You are waay to fast for me  ;D

I was still struggling with some modulo that decided to waste my time (you know when staring at your code and simply do not see it while it is right in front of you ?).

I thought I was going insane so questioned everything, even about my own internal used storage format. Eventually used raw data to check if everything was allright by using this very nice site

First picture is how it was, second how it should be  :P

Now, i'm going to take a small break and after that going to read your endevours. I was already checking up on some documentation but the sad thing is that the only thing I was able to find where posts from people more experienced (such as peterK) that don't have official documentation either.


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #46 on: March 13, 2023, 09:12:29 AM
I certainly know that feeling when I'm looking at the code repeatedly and it's not working. But there's an easy solution. The only thing to do is to set it aside till the next day. The solution is usually quite simple. It was there all the time.

rawpixels.net Oh, that's Lena.  :)

When scanlines should be modulus and they aren't it can cause problems such as with ILBM which must be modulus 16. I discovered that the hard way.

I'm still not 100% sure about the image data format for the IMAG chunk but using an Image Decoder similar to Decode35 that returns chunky bytes for the index values is better because it gives more control for adding padding bytes for each scanline. Then we just use chunky to planar conversion with bitplane reduction for each scanline. Then copy the planar scanlines in sequence to the output buffer. The image data is only 2 or 3kb in size so just write it to the ILBM all at once after converting chunky to planar.

It's interesting that the key functions that do the most are the smallest as far as lines of code. They are less than 30 lines each for Decode35, MakePlanar & ChunkyBytesToBitplanes. I don't have a working sample yet but the pieces are all there to read an icon & save images.

As far as documentation for Glow Icons and ILBM file format there isn't much readily available. PeterK provided some information about the ARGB data chunks. I think I provided that in my zip archives that I posted here for you.

I had to learn many things about ILBM on my own with trial & error methods. The same is true for IFF Icon Data & Classic Icons. The standard documentation provides a good framework but for specific information we just need to have a good understanding of the file format.

Once I learn more about the format of the image data in the IMAG chunk of the IFF data I may write an addendum to Amiga Icon Format explaining the structure of the IMAG chunk and the ARGB chunk for others to read about.

Everyone should have access to this information. I should also put together a text document or PDF about the ILBM file format and how to write or modify picture datatypes.
« Last Edit: March 13, 2023, 10:13:20 AM by miker1264 »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #47 on: March 13, 2023, 10:36:39 AM
@magorium

Amiga Icon Converter on GitHub is written in Java to display Amiga Icon Images in a browser window.

The file icon.js contains lots of information about the structure of the IMAG chunk and the ARGB chunk. But I don't read Java very well.

Interestingly the way it reads the image data is nearly identical to the AROS IMAG Image Decoder called Decode35. I have attached readIFFICON.txt source from icon.js so you can take a look. It provides insight into exactly what Decode35 in AROS Icon Library does and it gives clues about the image data format in the IMAG chunk.

Have a look also at convertRLE in ilbmtoicon. It converts chunky bytes into image data to write to an IMAG chunk.
« Last Edit: March 13, 2023, 11:15:02 AM by miker1264 »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #48 on: March 13, 2023, 12:45:14 PM
Hmmm...almost successfully saved IlBM files.  ;)

The two small images are the icon images saved as ILBM files.

The images are skewed because although the planar linesize is 48 I only wrote 46 bytes per line.

So the two padding bytes at the end of each planar scanline are missing.

But my two new functions MakePlanar & ConvertBytesToBitplanes are working to convert chunky to planar!



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #49 on: March 13, 2023, 01:36:46 PM
SaveImage is now working!   ;)

I'm reading an Amiga Glow Icon to get the offset to the IFF data. Then I read the IFF data to get to the IMAG chunk.

I use an Image Decoder to read the image data that then outputs chunky bytes for the index values of the colormap.

I then have to add padding bytes to the end of each scanline. In the case of an icon image 46x46 it should be an aligned width of 48 so I add two bytes.

The last step is to convert each chunky scanline into planar data to write to the ILBM file for the height of the image.


P.S. - This a prototype of the entire process. I'm saving 8bitplanes at the moment to test the chunky to planar conversion. Next I will used the real depth which is 4 & 5 bitplanes respectively.



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3755
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #50 on: March 13, 2023, 01:38:58 PM
Nice, great interesting tool that was missing on AROS !


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #51 on: March 13, 2023, 01:44:43 PM
Nice, great interesting tool that was missing on AROS !

This is intended to be a method to split an Amiga Glow Icon into two ILBM images using only native methods. No libraries and no OS functions. We read the binary from the files directly and copy data and mask and bit shift as needed.

I'm working on a prototype for AROS.

magorium is working on a portable version for Windows x64.

It's looks very promising so far but there's more to do.  :)



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3755
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #52 on: March 13, 2023, 02:48:32 PM
Icons with ILBM images are great for OS3 PAL systems, Icons with PNG Images are better suited for RTG systems.

Also, creating Icons with ILBM Images on Windows is complicated, most Windows Graphics Editors do not use this format


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #53 on: March 13, 2023, 03:40:54 PM
Icons with ILBM images are great for OS3 PAL systems, Icons with PNG Images are better suited for RTG systems.

Also, creating Icons with ILBM Images on Windows is complicated, most Windows Graphics Editors do not use this format

I don't think the idea is to create icons on Windows but there are some nice paint programs that can be used.

Mostly the purpose of the icon splitter is to split PNG icons without having to do it manually. Being able to split Glow Icons is simply a bonus. We wanted to see if it can be done.



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3755
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #54 on: March 13, 2023, 06:07:14 PM
Yes it is useful, it happens to me that sometimes I accidentally delete some Icon images, and I use with Icon Editor to split my Icons and take the 2 images.

Regarding Windows, to ceare and shape the images I use Photofiltre free version, very simple child proof, very convenient and fast in working with transparencies, then I create the Icons with OS3 version of IconEditor with my AfA One, which is very fast, and most of all convenient because of the possibility to have the thumbnails "the preview" of the PNG images.


magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #55 on: March 13, 2023, 08:05:22 PM
Hello miker,

I have taken a (quick) look at your attachments. Thank you for those.

fwiw: I have put the ILBM writer on the back-burner for the moment (as long as not meddling with ham, ehb, pbm, acbm etc then implementing it should not be too hard to do). I now have working code for handling FACE/ARGB. Currently working at IMAG.

I'm still attempting to write my code based on my own interpretation but atm seem a bit stuck. As you have already mentioned the RLE encoding seems a bit different than you average run length encoding (that is used by ILBM).

edit: problem seems "unstucked" no to check if my rle decoding works. As always it is the one typing things on the keyboard that is at fault  :P
« Last Edit: March 13, 2023, 09:07:17 PM by magorium »



magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #56 on: March 13, 2023, 08:21:56 PM
magorium is working on a portable version for Windows x64.
Actually for every target that is supported by Free Pascal but atm I have only the Win64, Linux64, MorphOS, AmigaOS4 and classic AmigaOS68k (cross) compilers installed.

@AMIGASYSTEM:
We are working on tools that are able to aid your graphical adventures on/for whatever platform you prefer. There are not a lot of Linux/Windows tools that allow you to read/display and split images found in Amiga .info files.

The extraction of the images inside icons is especially useful if you want to apply a graphical effect to one or both of the images, and our tools can help automated some of that process.
« Last Edit: March 13, 2023, 08:25:42 PM by magorium »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #57 on: March 13, 2023, 11:24:13 PM
@magorium

The key to understand the image data in the IMAG chunk can be found in ReadIFFIcon in icons.js of Amiga Icon Converter on GitHub. The notes & code explain it all.  :)

My prototype code is working to export ILBM images. Now I have to transfer the main functions to another more streamlined program (I have to re-write everything) .

No worries on the timeline. The aiix tool works!
« Last Edit: March 13, 2023, 11:28:18 PM by miker1264 »



magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #58 on: March 14, 2023, 02:12:09 AM
@miker:
Your explanation and example code for rle decoding saved the day for the last few (literal) bits.

Thank you very much for that miker1264.


IMAG chunks are now working for me as well, see attachment.

Need a lot of code cleanup, comments, abstraction and a complete rewrite to be able to add it to aiix.

output of test_icon program:
Code: [Select]
./test_icon icons/a.info
formtype = 49434F4E
reading chunk FACE
fc.Width           = 46
fc.Height          = 46
fc.Flags           = 0 ()
fc.Aspect          = 42
fc.MaxPaletteBytes = 18766
reading chunk IMAG (774 bytes)
imag.Transparent = 0
imag.NumColors   = 21
imag.Flags       = 3 (has_transparent_color has_palette )
imag.ImgFormat   = 1 (rle compressed)
imag.PalFormat   = 1 (rle compressed)
imag.Depth       = 5
imag.ImgSize     = 707
imag.PalSize     = 57
image and palette size fits in chunk
read 707 bytes from stream into compressed buffer (707 bytes)
read 57 bytes from stream into compressed buffer (57 bytes)
here we should decompress the palette
decoding palette succeeded
here we should write the pixels into a image file and save it
Pixelbuffer contains 2116 bytes
Palette contains 63 bytes
out of bound = 0
inbound = 2116
reading chunk IMAG (1051 bytes)
imag.Transparent = 0
imag.NumColors   = 0
imag.Flags       = 1 (has_transparent_color )
imag.ImgFormat   = 1 (rle compressed)
imag.PalFormat   = 0 (uncompressed)
imag.Depth       = 5
imag.ImgSize     = 1041
imag.PalSize     = 1
image size fits in chunk (no palette)
read 1041 bytes from stream into compressed buffer (1041 bytes)
no palette present for this IMAG chunk. Need to rewrite code to re-use first palette


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #59 on: March 14, 2023, 02:16:44 AM
@miker:
Your explanation and example code for rle decoding saved the day for the last few (literal) bits.

Thank you very much for that miker1264.


IMAG chunks are now working for me as well, see attachment.

Need a lot of code cleanup, comments, abstraction and a complete rewrite to be able to add it to aiix.

That's fantastic! I'm glad your code works too.

I need some code cleanup, more concise comments, streamlining and a re-write to make it all work as well.