icon splitter

magorium · 7221

magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
on: March 04, 2023, 12:45:24 PM
Taken from another thread in order to not pollute.

If you could write a program that splits PNG Icons or Classic Icons that would be great. If you could compile it for Windows & AROS that's even better. Many times on Windows I have to use the Hex Editor to do it.

@Miker1264:
A few questions:
1) what to do with the Ic0n chunk in png images. I have seen icons that even have a ic0n chunk in both images.
2) I assume that writing the individual images to a standard png image would be ok ?
3) what would be a preferred storage format for classic icons (you mentioned ilbm but what exact format) ?
4) would you also like to have support for newicons (e.g. tooltype icons)
5) in case yes to 4, what about the classic images ?

Anything else I forgot to yo might think is a good idea to add/implement, please share.

If there is any priority with regards to a particular icon storage format then please give a note on that. f.i. splitting png images is a matter of writing 2 or 3 lines of code (if I would to use a pre-existing  png class loader) while others like newicons requires a bit more work (especially since i did not write a decompressor for that format yet).

Streamlining everything into a single command line program would add some additional time as well.


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #1 on: March 04, 2023, 02:32:29 PM
Taken from another thread in order to not pollute.

If you could write a program that splits PNG Icons or Classic Icons that would be great. If you could compile it for Windows & AROS that's even better. Many times on Windows I have to use the Hex Editor to do it.

@Miker1264:
A few questions:
1) what to do with the Ic0n chunk in png images. I have seen icons that even have a ic0n chunk in both images.
2) I assume that writing the individual images to a standard png image would be ok ?
3) what would be a preferred storage format for classic icons (you mentioned ilbm but what exact format) ?
4) would you also like to have support for newicons (e.g. tooltype icons)
5) in case yes to 4, what about the classic images ?

Anything else I forgot to yo might think is a good idea to add/implement, please share.

If there is any priority with regards to a particular icon storage format then please give a note on that. f.i. splitting png images is a matter of writing 2 or 3 lines of code (if I would to use a pre-existing  png class loader) while others like newicons requires a bit more work (especially since i did not write a decompressor for that format yet).

Streamlining everything into a single command line program would add some additional time as well.

All good questions.  :)

When splitting the PNG icon into images store as PNG images. I usually assign names such as Img1.png & Img2.png or some variation. But be prepared if there is only one image. Maybe offer an output path different than the input icon path. Or default could be if output not specified save images to same location as the original icon file. It's ok to leave the icOn chunk in the first PNG image. That contains the active icon attributes. I believe that icOn chunks in second images may be unused.

When saving Classic Icons we are only concerned with the IFF icon images. The IFF Data starts with "FORM....ICONFACE". Save the ILBM file as the actual number of bitplanes & index values & colormap from the icon data. Once you extract the images & colormap it's easy to write the ILBM. To make it easier ILBM can be uncompressed planar images & colormap. There is information for ILBM format if you search for IFF85.

Sometimes Classic Amiga Icons contain OS3.5 IFF Data & ARGB data chunks attached to the end of the file. See Icon Library for methods to read the zlib compressed 32bit data.

The easiest way to split PNG icons & retain the icOn chunk is to find the first 'IEND' & second 'IEND' if there is one then calculate filesize1 & filesize2 then read & write binary. You could use another method to get the images but the icOn chunk may be lost unless you locate it just before 'IEND' then save it to .bin file or store it some other way to later write to file. As far as classic Icons you can just read them sequentially. For AROS we can just use IconControl functions but for Windows or an OS other than AROS you need another method to read the icon data.

« Last Edit: March 04, 2023, 02:42:47 PM by miker1264 »



magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #2 on: March 04, 2023, 03:35:59 PM
Thank you Miker1264 for your swift and elaborated reply.

I'll see what I can do  :)

Do you have preference wrt win32/win64 ?


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #3 on: March 04, 2023, 04:38:43 PM
Thank you Miker1264 for your swift and elaborated reply.

I'll see what I can do  :)

Do you have preference wrt win32/win64 ?

I use Windows 64bit. If that's what you meant to ask. I use it for editing code & painting icons.



magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #4 on: March 05, 2023, 04:19:53 PM
Thank you miker.

I required the info so that I could build and setup the correct cross-compiler.

Attached you will find a zip file that contains v0.0.1 of the aiix command line tool.

It is a pre-test and i would kindly ask if you could test and report back if the executable works for you (I can't test myself) so that I know that I'm on the right track or if I need to make (other) adjustments to my setup. It should be a x86_64 bit executable.

The tool itself is able to extract png image(s) based on the provided filename (e.g. test.info) and will write out the png images (for now in the same directory the provided filename is/was given), and tell you if if it was able to detect them. If the provided filename does not contain any png images then the tool will inform about that as well.

The filenames of the saved images are based on the original provided filename with an additional (hexadecimal) offset where the png image was located in the original file, and with a png extension.

Hardly any error-checking is currently provided so please keep that in mind.

If at any point you would like to compile the tool yourself or have a look at the source then just send me a pm.

Code: [Select]
$ aiix test.info
Amiga Info Image eXtractor v0.0.1
located 2 png images in file "test.info"
extracted 2 image(s) to file

Code: [Select]
$ aiix aiix.pas
Amiga Info Image eXtractor v0.0.1
located 0 png images in file "aiix.pas"
extracted 0 image(s) to file

Code: [Select]
$ aiix
Amiga Info Image eXtractor v0.0.1

aiix <infofilename>

todo: write help


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #5 on: March 05, 2023, 05:00:02 PM
Which OS is your tool compiled for? I assume AROS x86-64.

Also if it is AROS then is it for ABIv11 x86-64 or ABIv1 ?

Is the syntax aiix [file.info]



magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #6 on: March 05, 2023, 05:04:50 PM
Which OS is your tool compiled for? I assume AROS x86-64.
Apologies as it is my bad that i forgot to mention it. Windows  64 bit:)

Quote
Also if it is AROS then is it for ABIv11 x86-64 or ABIv1 ?
If it is to become for AROS then it would initially be AROS ABiv0. AROS ABIv1 is not supported by Free Pascal atm and my AROS ABiv11 merge requests for Free Pascal are still in limbo  :-X

Quote
Is the syntax aiix [file.info]
Correct.

Sorry for the inconvenience.

Current possible targets that are relevant and I am able to compile for are: amiga-m68k, ppc-morphos, ppc-AmigaOS4, win 32/64 bit, linux 32/64 bit. Besides some other exotic targets that I currently have setup some others require for me to setup a cross-compiler. AROS target is a work in progress (but will be there eventually)
« Last Edit: March 05, 2023, 05:11:22 PM by magorium »



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3740
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #7 on: March 05, 2023, 05:17:59 PM
magorium, I tried AIXX on my Win7 64Bit on my DualPNG Icons and it worked, the two images were extracted correctly, see screenshot.

I will try if it works with OS4 and OS 3.9 Glow icons, I will also try with a BAT file, so I can extract the images on many icons at once!


magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #8 on: March 05, 2023, 05:39:42 PM
Thank you for testing and reporting back AMIGASYSTEM

If you have any suggestions to improve the tool (besides the suggestions already pointed out by user Miker) then feel free to suggest/ask.

The current executable is/was just a simple test to see if the executable works as intended.

Next on my list is support for the glowicons (as they seem the easiest to extract the images from) and then newicons. Support for (classic) bitmap images will probably follow after that.


AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3740
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #9 on: March 05, 2023, 06:10:23 PM
I tried extracting images from many icons at once, but with the parameter
aiix *.info the files are not found again, maybe it would be needed a little GUI


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #10 on: March 05, 2023, 06:17:39 PM
@magorium

The aiix icon tool works on Windows 7 Pro 64bit.

It split the icon into two images with correct offsets.

You mentioned your build system. It would be great if you could also compile it for AROS ABOv0 for splitting icons.

I'm currently refreshing my ABIv11 sources then I have to rebuild the tool chain. Last time it took 3 hours.  :o



magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #11 on: March 05, 2023, 06:17:46 PM
@AMIGASYSTEM:
you are going waaay too fast for me dear padawan  :)

This version is not even close to an alpha release, let alone that it supports file-pattern matching.

There is no need for a GUI (unless you really want to). I have no idea how to do it in a Windows shell/terminal but in Linux I can do something like:
Code: [Select]
for file in *.info; do ./aiix "$file"; done;
I know there is a Windows shell/bat file equivalent but I simply do not remember how that used to work in Windows.


On a completely other note. I did not test it but I came across a tool that seems to be able to extract image(s) from Amiga icons (amongst other files). It is called deark and can be found here. Perhaps that is able to fulfill some (current) needs.


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #12 on: March 05, 2023, 06:24:07 PM
@AMIGASYSTEM:
you are going waaay too fast for me dear padawan  :)

This version is not even close to an alpha release, let alone that it supports file-pattern matching.

There is no need for a GUI (unless you really want to). I have no idea how to do it in a Windows shell/terminal but in Linux I can do something like:
Code: [Select]
for file in *.info; do ./aiix "$file"; done;
I know there is a Windows shell/bat file equivalent but I simply do not remember how that used to work in Windows.


On a completely other note. I did not test it but I came across a tool that seems to be able to extract image(s) from Amiga icons (amongst other files). It is called deark and can be found here. Perhaps that is able to fulfill some (current) needs.

For Windows cmd it should be aiix *.info

Then it should split every .info file in the directory into images in batch mode.

AMIGASYSTEM does that to me too! He puts the cart in front of the horse! Whoa!! We aren't there yet.  ;D



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3740
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #13 on: March 05, 2023, 06:29:39 PM
Actually that is the command BAT, I use it with "XDMS" for multiple conversion of .DMS files to .ADF, and then after the conversion the deletion of the source files

The command I use is this:

attrib -r -s -h *.* /s
XDMS U *.DMS
Del *.DMS




magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #14 on: March 05, 2023, 06:32:11 PM
The aiix icon tool works on Windows 7 Pro 64bit.

It split the icon into two images with correct offsets.
Thank you for testing and reporting back :appreciated:

Quote
You mentioned your build system. It would be great if you could also compile it for AROS ABOv0 for splitting icons.
Yeah, will do that.

I'm working at a newly setup machine and haven't gotten around setting up Free Pascal completely yet. The binutils for AROS are (as always) a crime to create (I only need the standalone binutils and that requires a bit of work when getting the correct patches from the AROS repo's, apply and build the binutils).

Quote
I'm currently refreshing my ABIv11 sources then I have to rebuild the tool chain. Last time it took 3 hours.  :o
Yes, I know  :'(

I am blessed with Free Pascal in that I am able to create the host, 8 cross-compilers with required binutils in about half an hour. Only AROS keeps being a PITA (actually the gnu binutils)