Connect
[Workbench Icon Question]

I am curious about icon creation and manipulation from an OS API level. Are there methods for any of the following things in Amiga OS? If not, any ideas on how to do so programmatically?

+ Creating icon (.info) from image in memory?
+ Are there differences in OS 1.x, 2.x and 3.x one should be aware of
+ How do icons of different depths work? 1bp (2 colors), 2bp (4 colors), 3bp (16 colors), etc..
+ Are there different APIs (if there are any APIs at all) for disk.info vs. <file|drawer>.info icons
+ Telling WB to refresh its display/cache of a given icon when changes are made?
Jon-lennart Aasenden: There are 4 icon standards. I have some js code that decodes and creates icons if you like it? Icons can be created via the icon.library api functions
Brielle Harrison: I'll see if I can't find and link some references to the RKRMs here.
Brielle Harrison: Amazing @develin, thanks for sharing
Stefan Blixth: @nyteshade I went a little deeper in the subject now and found some GPL sources in the MorphOS desktop (Ambient) that might be useful. If you locate the Ambient archive from this page : https://www.morphos-team.net/sources you can find some useful code for the icon handling under the folder iconlib/ in the archive. For my own needs the file getimage.c is very useful =)
Brielle Harrison: GetDiskObject() or GetDiskObjectNew() take a STRPTR but I can’t seem to pass a path to an icon there. What values does it take? RKRMs aren’t helpful here. @develin
Stefan Blixth: @nyteshade I think if I recall it right that you shall ignore the .info-part just use the filename as string as an argument. ie. struct DIskObject *do_var = GetDiskObject("Myfile" );
Stefan Blixth: If you obtain a do_var you can then check the do_var->do_DrawerData (if it exists etc.) and also do_var->doType etc.
Brielle Harrison: Once the variable is non NULL, this makes sense. Once I have another chance I’ll try omitting the .info from the file name and try again.
Brielle Harrison: @develin assuming I get it working and I update the DrawerData struct’s CurrentX and CurrentY values, how to i programmatically tell workbench to update its position? Is there an API for that?
Stefan Blixth: @nyteshade This is just for adjusting the position on the "disk" as per se or do you mean like in an inconify way ? if you use PutDiscObject() it will according to RKRM : " As of release V2.0, PutDiskObject (if sucessful) notifies workbench has an icon has been created/modified." so that shall update the position I think without any force for redraw is needed. I know that there was some workbench-API added to 3.9 etc. that you could make "leave outs" of icons just like an cx_broker object (iconify).
Brielle Harrison: An example app I plan to write is something to organize and save the position of icons within a drawer on disk in a manner I prefer. This should be an easy way to start working with the API.
Brielle Harrison: @develin so had a chance on the train to check. It does in fact work if I omit the .info. Thanks for that. Do you happen to know how DiskObject.do_Gadget.LeftEdge and TopEdge relate to the icon? They seem to be the do_CurrentX and do_CurrentY values plus some arbitrary value. First glance seems like it’s not icon size added to the DiskObject’s x and y but I didn’t really do the math. Also it’s not clear why I wouldn’t use DrawerData’s X and Y but they seem not to be in use.