IconClone Icon Exchange

miker1264 · 2662

miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
on: July 21, 2022, 11:38:14 PM
I released version 1.07 of IconClone on AROS Archives about six months ago.

The newest version can load & display Classic Icons as well as PNG Icons.

But there seems to be a slight problem with GetDiskObject in Icon Library. It changes the pointer data in the DiskObject in memory.
These functions to load the icon into a DiskObject structure seem to be in "diskobjio.c" in Icon Library.

It replaces gadgetrender, selectrender, tooltypes, drawerdata & imagedata non-zero values with 0xFE CA AD AB.
According to documentation these values are special pointer types:
"In memory it is a pointer to data, in file it should be treated as a boolean value (if not zero, the data is present)
(if set to zero, data is not present)"

ilbm2icon simply uses two Boolean Values:
BOOL_YES = 0x2A2A2A2A
& BOOL_NO = 0x0000
 
When the Boolean values are replaced with FE CA AD AB such as after GetDiskObject/PutDiskObject the icon can't be read sequentially.
But when I "repaired" the file by replacing FE CA AD AB values with 2A2A2A2A it displayed perfectly. These values are all LONG.

This test was done using IconClone x86 on AROS One x86. I plan to do some more tests with AROS 68k as well in the next few days.









magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #1 on: July 22, 2022, 12:30:30 AM
Thank you very much for moving the progress your efforts to a better home.


Nice find !


Just a remark from someone who doesn't know anything on the subject but that strikes me a bit as the generic checking that a c compiler does:
"if var then" which becomes: if value of var <> zero.


In such case it actually does not matter what the value of var is, as long as it is not zero the condition becomes true. If someone or some code actually starts checking the value of var then Houston has a problem  :)


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #2 on: July 22, 2022, 12:40:25 AM
Thank you very much for moving the progress your efforts to a better home.


Nice find !


Just a remark from someone who doesn't know anything on the subject but that strikes me a bit as the generic checking that a c compiler does:
"if var then" which becomes: if value of var <> zero.


In such case it actually does not matter what the value of var is, as long as it is not zero the condition becomes true. If someone or some code actually starts checking the value of var then Houston has a problem  :)

That's true. We don't check the actual value. It is treated as a special boolean value. If it is all zeros then the value is zero. But if it is any positive value that is non-zero then it is 1. Boolean Yes or Boolean No. It's either 1 or 0.

But the value that is written as a non-zero placeholder creates unexpected results when reading the file sequentially.

There is something odd about 0xFE CA AD AB.
But 0x2A2A2A2A works fine & any other non-zero value works. But not that one.
« Last Edit: July 22, 2022, 12:44:45 AM by miker1264 »



magorium

  • Legendary Member
  • *****
    • Posts: 632
    • Karma: +62/-0
  • Convicted non contributor
Reply #3 on: July 22, 2022, 01:07:28 AM
There is something odd about 0xFE CA AD AB.
There is... take a closer look and try spell it in backwards byte order.

How/why that should impact gadget render images, I have no idea.

edit: on 2nd though, maybe i do.
What if the gadget structure and flags do not fit the criteria as described in the manuals ? perhaps that would account for providing a special value for the gadget render image pointer (although I have not seen written proof of what that value should be so can't verify on the value you posted). For a fast read, see https://wiki.amigaos.net/wiki/Intuition_Gadgets#Gadget_Structure
« Last Edit: July 22, 2022, 01:23:12 AM by magorium »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #4 on: July 23, 2022, 06:56:10 PM
Good news!

I could not use the Classic OS3.5 icon file produced by GetDiskObject/PutDiskObject. There's likely nothing wrong.

But my Icon Clone program couldn't read it sequentially to get the offset to OS35 IFF Data.

So instead I wrote a function Save_Classic_Icon that writes the entire Classic Icon to a file.

Save_Classic_Icon is working! But it just needs a little fine tuning then Icon Clone can exchange Classic Icons.  :)

It uses a source icon file and original icon file as input and it writes an output file that is a synthesis of the two icons.

The original icon has the icon attributes that we want to preserve such as icon type, default tool, tooltypes, stacksize and drawer data. The source icon contains all the image data. The output file then takes the place of the original icon file which now has new images.

In the future we will be able to convert a PNG icon using color quantizing into 8bit images that could then be written to a Classic OS3.5 Icon File with or without ARGB data chunks. So we can now convert PNG Icons to Amiga Icons.



« Last Edit: July 23, 2022, 08:21:00 PM by miker1264 »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #5 on: July 26, 2022, 09:52:01 AM
I have resolved the problem with loading Classic Amiga Icons.

IconClone had an issue reading the Special Boolean Values. But in reality they are either BOOL_NO=0 or BOOL_YES=1.
So the values can only be zero or other than zero. So I used Magellan to do an Icon Exchange for Screen_Mag.info &
then noticed that the Special Boolean Values were all set to 0xFE CA AD AB ("A BAD CAFE") & it could be any value
like 0xBAD DECAF if you don't like decaf.  :D

So I realized I only needed to change the way IconClone evaluates the BOOL_YES or BOOL_NO such as the following:

//firstimage = (GetUint32(Buffer32)>0) ? 1: 0; //22

firstimage = (GetUint32(Buffer32)==0) ? 0: 1;

Instead of testing whether the value is greater than zero so it equals one the better technique is test for zero values.
If it is not zero it is one. Very easy evaluation. So now it all works as expected.

But I'm glad I wrote the functions to save Classic Amiga Icons. I will use it in my next Icon Application to make Amiga Icons.  8)

@magorium Thanks for the subtle clue to solve the puzzle.

















« Last Edit: July 26, 2022, 10:11:40 AM by miker1264 »



cdimauro

  • Member
  • ***
    • Posts: 164
    • Karma: +26/-1
Reply #6 on: July 26, 2022, 02:25:16 PM
So I realized I only needed to change the way IconClone evaluates the BOOL_YES or BOOL_NO such as the following:

//firstimage = (GetUint32(Buffer32)>0) ? 1: 0; //22

firstimage = (GetUint32(Buffer32)==0) ? 0: 1;

Instead of testing whether the value is greater than zero so it equals one the better technique is test for zero values.
If it is not zero it is one. Very easy evaluation. So now it all works as expected.
This:
Code: [Select]
firstimage = GetUint32(Buffer32) != 0;should equivalent to the above.



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #7 on: July 26, 2022, 03:17:25 PM
So I realized I only needed to change the way IconClone evaluates the BOOL_YES or BOOL_NO such as the following:

//firstimage = (GetUint32(Buffer32)>0) ? 1: 0; //22

firstimage = (GetUint32(Buffer32)==0) ? 0: 1;

Instead of testing whether the value is greater than zero so it equals one the better technique is test for zero values.
If it is not zero it is one. Very easy evaluation. So now it all works as expected.
This:
Code: [Select]
firstimage = GetUint32(Buffer32) != 0;should equivalent to the above.

That would likely work. Thanks.

I can use the code to Write Classic Amiga Icons in my next Icon Application.

It will have two display areas featuring Drag-n-drop like IconClone. It will "press" two images together to make an icon. The images can both be PNG or ilbm but they both must be the same type. There will be two buttons on the bottom "Save Icon" & "Save ARGB".

When you load two ilbm then choose Save Icon it saves a Classic Amiga Icon with OS35.5 Extension. When you load two PNG images then choose Save Icon it saves a DualPNG. When you drop two PNG images then choose Save ARGB it saves a Classic Amiga Icon with OS3.5 Extension & ARGB data chunks.

It may be called "Icon press" for lack of a better name.

It should progress very rapidly since much of the code is done already. More tools is better.  :)


« Last Edit: July 26, 2022, 03:29:38 PM by miker1264 »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #8 on: July 29, 2022, 09:13:04 AM
Icon Clone v1.08 is almost ready for release.

I will likely upload all versions to AROS Archives then provide links.

The important thing is that is works for AROS 68k & x86 & x86-64.  :)



Amiwell

  • Legendary Member
  • *****
    • Posts: 2616
    • Karma: +35/-4
  • Peace
Reply #9 on: July 29, 2022, 11:14:28 AM
thank you Miker



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3741
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #10 on: July 29, 2022, 02:58:31 PM
As soon as it is available for download I will test IconClone on AROS One x86 and AROS One 68k

Which icon of mine did you choose from the ones I sent you?


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #11 on: July 29, 2022, 05:40:51 PM
As soon as it is available for download I will test IconClone on AROS One x86 and AROS One 68k

Which icon of mine did you choose from the ones I sent you?

I like the last one you made from the clip art I posted with the arrow. I like the others also but that one seems nice.

I I'll post the release zip files later today or early morning.




miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #12 on: July 29, 2022, 10:18:23 PM
Icon Clone may seem like yet another Icon Exchange Utility.

But it has a interesting property. I don't know of any other Icon Exchange App that allows you to "Reverse" the Exchange. Icon Clone can perform the exchange then when the user presses the exchange button again it acts as a toggle that reverses the icon exchange.

Two diskobjects that represent Source & Destination (Original) are held in memory. When the user presses the exchange button the first time the exchange happens normally from Source to Destination & a boolean value is also set. Before the exchange BOOL reverse = FALSE. After the exchange it equals TRUE. The next time the user presses the button "If reverse ==TRUE" then swap Source DiskObject & Destination DiskObject and perform the exchange again. The Original Icon reappears.  :)

It's fun to keep pressing the exchange button to watch the icons exchange images then change back again.

I plan to make a command line version of Icon Clone that is a one-way operation. It can be used with a script to exchange icon images for complete iconsets using icon lists.

I wanted to post the release files on AROS Archives then post the links here but why spoil the fun! Here they are...

The source code is included in each zip file  with the corresponding binary. I'm sure the code could be more efficient and cleaner. There will small updates from time to time.

« Last Edit: July 29, 2022, 11:58:42 PM by miker1264 »



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3741
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #13 on: July 30, 2022, 12:51:26 AM
Outstanding work miker, no problems detected on both x86 and 68k version, thanks

In the screenshot IconClone on AROS One 68k !


Amiwell

  • Legendary Member
  • *****
    • Posts: 2616
    • Karma: +35/-4
  • Peace
Reply #14 on: July 30, 2022, 06:03:51 AM
If you want them I publish them on Archives :)