English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 25 January 2023, 00:38   #1
walkero
Registered User

walkero's Avatar
 
Join Date: May 2012
Location: Dublin/Ireland
Posts: 210
Tooltypes update on NewIcons

In one of the applications I am working on, I deal with tooltypes and NewIcons. Unfortunately, if I get it right, the NewIcons save the image information at the same place where the do_tooltypes of the files is installed.


So, what I did was to get the new tooltypes the user provides and after that add the rest of the old tooltypes, and then write them in the icon using PutDiskObject().


The new tooltypes are written in the file but the image is lost. If I check the icon info from Workbench I see the image information as text like


Code:
*** DON'T EDIT THE FOLLOWING LINES!! ***
IM1=B?!WÑ_±Ô@0($£I4Ï_?¶2iCI¥»l·S;M§Œ®¿ÈJ5*e:mF¬ŸÇÌ9l·B1(b1(diD£FÄY®L§K7KŠŸJŠJ¿W2iD£T:-&#!b;-fµ2)!œÇ[M6kF#!`M6kP($")$b=nžSºÅËo
IM1=ožÄÉdB0ÃY<§+%biD£OÈÌÏŽQ©µR9(¥J5d³Q9\¯OI¥»YÍÏ_c²Á¹T:.°OšŽÂɲ0hD>/'`Ö
IM1="$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(0@a"$(

My question is if there is a specific way the NewIcons' tooltypes should be saved, so to keep the image data? Is there an easier way to deal with tooltypes, like clear all the old, add new and don't care about the image data, if there are any?


Thank you guys for your help and time.
walkero is offline  
Old 25 January 2023, 10:15   #2
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,732
I think there must be an empty line before that DON'T EDIT... line.

And the whole thing must be at the end of the tooltype array.

And of course you have to keep it all intact. IIRC all those IM1= and IM2= lines have the same length. So your quote here looks somehow damaged.
thomas is offline  
Old 25 January 2023, 16:31   #3
walkero
Registered User

walkero's Avatar
 
Join Date: May 2012
Location: Dublin/Ireland
Posts: 210
Thank you Thomas for your response

Quote:
I think there must be an empty line before that DON'T EDIT... line.
Maybe I missed adding that. So this is crucial for the image to be shown, right? If that's the case, do you know why is it before the "*** DON'T EDIT...." line?
Is there a possibility that the image will break if there are extra lines after the image text?


Quote:
And of course you have to keep it all intact. IIRC all those IM1= and IM2= lines have the same length. So your quote here looks somehow damaged.
I am not sure what kind of info the NewIcons store, but if I understand it right, the width of those lines might be wrong because some hex codes might not be able to be presented as text.

What I am doing is getting the new tooltypes into the tooltype array and then adding the newicon tooltypes from the "*** DON'T EDIT...." line until the end of the data. My what I need to do is to make sure the line before the "*** DON'T EDIT...." line is there and if it work with it.

Do you believe there should be a better way to do things like that in the OS3 NDK? I mean, WB already know about the different icons, and the way to manipulate them should be already implemented, right? Having a way to save new tooltypes in a more secure way I believe would be necessary, especially in situations where the user is free to change all the tooltypes as he likes. So, would it make sense for the PutDiskObject() make sure the NewIcons are not deleted, and when you get the ToolTypes from such an icon, you should take only those, and not the image data.

I understand that the NewIcons are something like a hack, but it would be nice in my opinion to have methods that make sure these data are not overwritten. Just an idea.
walkero is offline  
Old 25 January 2023, 18:41   #4
Steffest
Registered User

 
Join Date: Jan 2017
Location: Antwerp / Belgium
Posts: 171
I happen to have written a newIcon decoder just this week.
There's not really a cast-in-stone spec but my take:

The Empty line before "*** DON'T EDIT THE FOLLOWING LINES!! ***" seems to be always there, but not really needed in all cases. At least according to the AROS source it's OK to leave out, but to be on the safe side I would just leave it in. (ref: https://github.com/aros-development-.../diskobjNIio.c )

The IM1= and IM2= lines are not always of the same length.
The first line contains the size, transparency and the palette, the other lines are Image data.
So the first line will probably differ in size, the last line as well.
The other lines will always be 127 chars before decoding.

To answer your question: If you want to keep the NewIcon, then yes: just copying the tooltypes (including the empty line) should keep the icon intact
(But as Thomas mentions: something in your example looks off, so you may want to double check your saved tooltypes are binary exact from the original)

The more sane approach IMHO would be to convert the icon to ColorIcon/GlowIcon format though ...
Steffest is offline  
Old 25 January 2023, 19:53   #5
PeterK
Registered User
 
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,156
If you use icon.library v44+ it will automatically cut off the NewIcon tooltypes from the array and stores them internally. So, in IconInformation, SwazInfo, RAWBInfo etc. you won't see these NewIcon tooltypes anymore on OS 3.5+. Saving usually creates OS 3.5 icons.

GetIconTagList() returns a DiskObject structure with a pointer to the do_tooltypes array, but without the NewIcon tooltype strings.

You should better use PutIconTagList() when you want to write your DiskObject structure with the new do_tooltypes array back to disk. There are some tags (see autodocs) to control the creation of NewIcon or OS 3.5 images:

Code:
	ICONPUTA_DropChunkyIconImage (BOOL) -- This tag can be used to
	    keep the chunky icon image data from getting written
	    to disk.

	    This tag defaults to FALSE.

	ICONPUTA_DropNewIconToolTypes (BOOL) -- This tag controls whether
	    any NewIcon tool types will be omitted when writing the
	    icon to disk. TRUE will omit the data.

	    This tag defaults to FALSE.
If you want to keep the NewIcon images then the icon.library will restore the image tooltypes automatically at the end of the array. No need to do it yourself. But I must admit that I never tried to write any program doing things like that.

Last edited by PeterK; 25 January 2023 at 19:58.
PeterK is offline  
Old 25 January 2023, 20:00   #6
walkero
Registered User

walkero's Avatar
 
Join Date: May 2012
Location: Dublin/Ireland
Posts: 210
Thank you all for your replies.
I don't have any remorse to drop the NewIcon tootypes, if that simplifies things and the image stays intact. Do you think though that this should be a user decision? I mean, should there be a way that the user approves it?

I believe most of the users won't even know what a newIcon does, or what would be the difference, but from an ethical point, should the user been asked?
walkero is offline  
Old 25 January 2023, 20:17   #7
PeterK
Registered User
 
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,156
On WB v44+ nobody will need the NewIcon images anymore.

But users of WB/Kickstart 3.0/3.1, who still have only the old icon.library v39/40 and the NewIcons patch installed on their systems, may prefer to keep these tooltypes.
PeterK is offline  
Old 25 January 2023, 21:11   #8
walkero
Registered User

walkero's Avatar
 
Join Date: May 2012
Location: Dublin/Ireland
Posts: 210
@PeterK
I implemented the PutIconTagList() with dropping the NewIconTooltypes which works great, keeping the image and making the info file much smaller, more than half in size. But as mentioned it doesn't work in 3.1. So I guess I should implement two solutions, and use one or the other based on the system version.
walkero is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with WHDLoad and Tooltypes klx300r support.Apps 14 06 April 2021 19:34
Icon tooltypes and stuff oRBIT Coders. General 22 23 May 2010 22:27
WHDLoad Tooltypes Aljrob project.WHDLoad 10 31 March 2007 16:49
Assigning tooltypes to files? Gnorman project.ClassicWB 2 06 March 2006 21:42
Tool to add tooltypes MarlboroMan request.Apps 1 18 May 2005 07:29

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:56.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Page generated in 0.07181 seconds with 14 queries