According to this (https://learn.microsoft.com/en-us/windows/apps/design/style/iconography/app-icon-construction#icon-scaling) guide on icon scaling, when creating a new icon for a Windows application, it is necessary to provide – at minimum – the sizes 16x16, 24x24, 32x32, 48x48, and 256x256 because if there's no pixel-perfect match, Windows will display the icon only after scaling it down based on where the icon is intended to be rendered in the application window. However, I've noticed that loading some icons using the LoadImageA function blurs them to such an extent that I feel there is something wrong:
(https://i.postimg.cc/Ln21w92b/ida.png) (https://postimg.cc/Ln21w92b)
The image shows a fragment of the "open recent" window of IDA Freeware 8.2, while the second fragment shows what I get when I load the exact same (128px) icon into my program using the following call to LoadImageA:
PUSH 10h ; LR_LOADFROMFILE
PUSH 128 ; Height
PUSH 128 ; Width
PUSH 1 ; IMAGE_ICON
PUSH OFFSET ICONNAME ; C:\Program Files\IDA Freeware 8.2\ida.ico
PUSH 0
CALL LoadImageA@24
Is it possible to somehow reduce the amount of scaling while loading icons from standalone filesapplied to scaled icons?
Does ida.ico have an icon of that size 128x128 in it? I don't have that program, so I cannot check this myself.
If not, it would be resized from an icon that it does have.
I would use Resource Hacker (http://www.angusj.com/resourcehacker/) to view ida (the executable) in it, to see what size are the icons in the ida.ico icon group.
A little later... after thinking about it....
That didn't make sense, since the icon is in ida's directory. You would need an icon editor to see then, the sizes of the icons in ida.ico.
No guarantee that it will have a 256x256 icon in it. No matter what Microsoft recommends.
QuoteApps should have, at the bare minimum: 16x16, 24x24, 32x32, 48x48, and 256x256. This covers the most common icon sizes, and by providing a 256px icon, ensures Windows should only ever scale your icon down, never up.
Oh Micro$oft... the bare minimum
used in practice is 32x32 for the Alt Tab icons. Which is perhaps the least frequent use of icons.
The most frequent use is captions, and they are 16x16 - see screenshot, the one to the right. So don't worry, Windows will upscale your 16p icons to 32p, and that's enough. Btw the main difference between the Ms Edge icon and the others is the number of colours used: 7 for the eye, 10 for the "big" PaintShop icon, and 558 for the Ms Edge icon.
Speculating here, couple of ideas:
- 128x128: doesn't seem like anything like a standard size for icons. Maybe the problem is trying to scale that odd size down? Although you do show that the other icon looks OK. Is that other icon the same size? how can you be sure of that? Do you have the actual icon file?
- What is the actual (displayed) size of that icon you show? Maybe scale that icon down that size, using an icon editor, try that one instead? (It should be one of the standard sizes you listed. I can't imagine it's any larger than 32x32; 48x48 is huge.)
If you don't have an icon editor, you could try Axialis (https://www.axialis.com/iconworkshop/) (30-day free trial), or IcoFX (https://icofx.ro/) (unlimited free use). Axialis seems by far a better package, including lots of sample icons.
Part of the issue is, I believe, no control over which icon in a multi icon group is loaded by LoadImage. The same for LoadIcon, I would think.
IDA free in 64 bits have 4 icon size: 16x16, 32x32, 48x48 and 256x256.
Are you sure that your program have only 1 icon size?
Quote from: jj2007 on September 14, 2023, 08:48:09 AMSo don't worry, Windows will upscale your 16p icons to 32p, and that's enough.
But but but ... won't that look crappy, upscaling to twice the resolution? The OP is concerned about the appearance of icons here.
IDA Pro 64
(https://i.postimg.cc/py4D8Kmw/IDA-icon.jpg) (https://postimg.cc/py4D8Kmw)
Hi kkurkiewicz
This icon "shark.ico" has 16x16, 32x32, 48x48, 64x64, 128x128 all 32bit bmp.
Test with it to see results
The size of the icon saved in ida.ico definitely is 128x128, and, as far as I can tell, that's the only version of the icon that's provided because inspecting ida64.exe with Resource Hacker also gives me only that one icon. In the snippet, I'm loading it using LR_LOADFROMFILE, but turning the icon into a resource and then loading it by ordinal or name – using either LoadImageA or LoadIconA – gives me the exact same result, and the same thing happens with other icons too. Obviously, IDA is not written in assembly, but is it possible that, when ida64.exe is run, the icon is loaded in some other way?
Quote from: NoCforMe on September 14, 2023, 11:30:47 AMWhat is the actual (displayed) size of that icon you show?
As far as I recall, the displayed size is 32x32.
Displayed where?
Also worth looking at these two functions: LoadIconMetric and LoadIconWithScaleDown
- https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconmetric
- https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconwithscaledown
Quote from: jj2007 on September 14, 2023, 07:08:40 PMDisplayed where?
On the left side of the title bar, just as in my original screenshot, but I "measured" it only in Paint—that is, I took a screenshot, opened it in Paint, enlarged the image to 1400%, drew a straight line next to the icon and read the size off the status bar :smiley:
Hi fearless
Quote from: fearless on September 14, 2023, 07:38:04 PMLoadIconMetric and LoadIconWithScaleDown
Thanks for the link, very useful.
I was not aware of these APIs. I read the documentation and it occurred to me that for some reason, MS does not provide the ANSI version.
Biterider
Quote from: kkurkiewicz on September 14, 2023, 06:26:03 PMQuote from: NoCforMe on September 14, 2023, 11:30:47 AMWhat is the actual (displayed) size of that icon you show?
As far as I recall, the displayed size is 32x32.
Well, that being the case. how about scaling the icon yourself to that size and trying it?
What's happening is that
someone (the little man inside the GDI
* engine) is scaling the 128x128 icon to 32 square, and not doing a particularly good job of it. Dunno if you can improve things by doing the scaling yourself beforehand, but maybe worth a try.
* I should say GDI+, or that other more newfangled Windoze graphics protocol that I'm totally unfamiliar with.
If original 64 bits program look different than in development 32 bit application, conclusion is: WOW64 is not using same resize method than 64 bits API. :thumbsup:
Quote from: HSE on September 15, 2023, 02:39:21 AMIf original 64 bits program look different than in development 32 bit application, conclusion is: WOW64 is not using same resize method than 64 bits API. :thumbsup:
That's an interesting theory. So, if an identical program would be built a) as 64-bit, b) as 32-bit application, its icon would look different? Can I have an icon to demonstrate this, please?
include \Masm32\MasmBasic\Res\JBasic.inc
wcx WNDCLASSEX <WNDCLASSEX, CS_HREDRAW or CS_VREDRAW or CS_OWNDC, WndProc, 0, 0, 1, 2, 3, COLOR_BTNFACE+1, 0, txClass, SIZE_P>
txClass db "JBasicGUI", 0 ; OPT_64 1 ; 0=32-bit, 1=64-bit assembly
Init
WinMain proc
LOCAL msg:MSG
wc equ [rbx.WNDCLASSEX] ; we use an equate for better readability
lea rbx, wcx
mov wc.hInstance, rv(GetModuleHandle, 0)
mov wc.hIcon, rv(LoadIcon, rax, IDI_APPLICATION) ; click on the first Rsrc bookmark to change the icon
mov wc.hIconSm, rax ; the rv macro returns results in rax
mov wc.hCursor, rv(LoadCursor, NULL, IDC_ARROW) ; get a cursor
jinvoke RegisterClassEx, rbx ; the window class needs to be registered
wsStyle=WS_OVERLAPPEDWINDOW or WS_VISIBLE or WS_CLIPCHILDREN
jinvoke CreateWindowEx, 0, wc.lpszClassName, Chr$("Hello World"), wsStyle, 300+320*@64, 127, 300, 200, NULL, rv(LoadMenu, wc.hInstance, 100), wc.hInstance, NULL
msgLoop: inc eax
shr eax, 1
je @F ; quit if GetMessage returned 0 (exit OK) or -1 (error), or if CwEx failed
jinvoke TranslateMessage, addr msg ; translates virtual-key messages into character messages
jinvoke DispatchMessage, addr msg ; dispatches a message to a window procedure
jinvoke GetMessage, addr msg, 0, 0, 0 ; retrieve a message from the queue, and return a BOOL
jmp msgLoop
@@: jinvoke ExitProcess, msg.wParam
WinMain endp
WndProc proc uses rsi rbx hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL ps:PAINTSTRUCT, MyR4:REAL4
Switch_ uMsg
Case_ WM_DESTROY: jinvoke PostQuitMessage, NULL ; quit after WM_CLOSE
Endsw_
jinvoke DefWindowProc, hWnd, uMsg, wParam, lParam ; default processing
ret
WndProc endp
EndOfCode
Is 128x128?
How look?
OK, I'll try resizing the icon using Axialis and see what happens, thank you.
And for those who would like to see the icon, you can find it in the attachment below.
Viewing Zedd's smallerized (32x32) icon, at least in Axialis's preview, it looks more like the IDA one (better) than yours (fuzzy). Let us know what it looks like displaying the smaller one.
Quote from: HSE on September 15, 2023, 02:39:21 AMIf original 64 bits program look different than in development 32 bit application, conclusion is: WOW64 is not using same resize method than 64 bits API. :thumbsup:
Here is Ida.ico, in 64- and 32-bit executables. See the difference?
Quote from: NoCforMe on September 15, 2023, 05:46:15 AMViewing Zedd's smallerized (32x32) icon, at least in Axialis's preview, it looks more like the IDA one (better) than yours (fuzzy). Let us know what it looks like displaying the smaller one.
It is a little smoother, but it still looks lousy.
(https://i.postimg.cc/K3vw29bN/new.png) (https://postimg.cc/K3vw29bN)
Quote from: kkurkiewicz on September 15, 2023, 05:56:51 AMIt is a little smoother, but it still looks lousy.
We have no idea at this point what apis or libraries that ida uses to display its icon (custom drawn?). But I agree, it looks better than the others.
Quote from: jj2007 on September 15, 2023, 05:53:09 AMQuote from: HSE on September 15, 2023, 02:39:21 AMIf original 64 bits program look different than in development 32 bit application, conclusion is: WOW64 is not using same resize method than 64 bits API. :thumbsup:
Here is Ida.ico, in 64- and 32-bit executables. See the difference?
No, because there isn't any. (I checked a blown-up image. The two are identical.) But Jochen, these are 16x16 icons.
I guess we really need to find out, somehow, exactly how Windoze is rendering these images on his window. Anyone have any ideas? Disassembly? Or how about using my strings program (attached) to see what Windows functions are being used in the executable? (This just pulls out all ASCII strings from a file and displays them.)
Quote from: NoCforMe on September 15, 2023, 06:10:01 AMThe two are identical. But Jochen, these are 16x16 icons.
Yes and no. It's a 128x128 icon, but Windows scales it down to 16x16 to let it fit into the caption. And it scales it down to 32x32 if you use Alt Tab.
I'd like to see
one example where Windows uses the full 128x128. And don't come up with an icon editor, because I would consider that cheating. I mean an actual use of this icon beyond 32x32.
:smiley:
Quote from: NoCforMe on September 15, 2023, 06:10:01 AMI guess we really need to find out, somehow, exactly how Windoze is rendering these images on his window. Anyone have any ideas?
Exactly. Without knowing how ida does it, no one can help kkurkiewicz with his dilemma.
Custom drawn window using GDI+ would be my
guess. Without knowing though, it is just speculation on my part.
IDA uses QtCore, QtGui and QtXml. You would need to look to those to find out what is going on.
IDA and Qt most likely have there own proprietary image storage/image manipulation solutions
for there user interfaces.
To see an example of the full size icon in use : Explorer -> View -> (in the Explorer ribbon) -> click "Extra Large Icons"
(https://i.postimg.cc/Xp29ytGQ/ida64.jpg) (https://postimg.cc/Xp29ytGQ)
:biggrin: Here no differences between 32, 64 or original IDA64.exe
Quote from: Caché GB on September 15, 2023, 07:16:28 AMIDA uses QtCore, QtGui and QtXml. You would need to look to those to find out what is going on.
IDA and Qt most likely have there own proprietary image storage/image manipulation solutions
for there user interfaces.
To see an example of the full size icon in use : Explorer -> View -> (in the Explorer ribbon) -> click "Extra Large Icons"
You don't need QT, simple Win32 is enough. "Extra Large Icons" is 64x64, but this is 128x128:
Quote from: Caché GB on September 15, 2023, 07:16:28 AMIDA uses QtCore, QtGui and QtXml. You would need to look to those to find out what is going on.
IDA and Qt most likely have there own proprietary image storage/image manipulation solutions
for there user interfaces.
Thank you, Caché GB
That is precisely what kkurkiewicz needs to know. Probably why resizing the icon down to 32x32 using the usual apis looks so bad.
Looking in running applications, happen that icon is stored double: large and small icon.
In 32 and 64 bits Masm32 SDK test apps both have 32x32.
In IDA Freeware large is 32x32 and small is 16x16 (inside a Qt class, etc)
Interesting thing is that "blur icon" is the 16x16 scaled to 32x32 (like SPY show).
My system only show 16x16 icons in window title bar, then I can't help to find differences :biggrin:
Which version number of IDA is that, HSE? The OP states that he is using IDA freeware version 8.2.
IDA have nothing to do. Problem apparently is related with "Scale Up", like Fearless think.
Quote from: kkurkiewicz on September 14, 2023, 06:17:31 PMThe size of the icon saved in ida.ico definitely is 128x128, and, as far as I can tell, that's the only version of the icon that's provided because inspecting ida64.exe with Resource Hacker also gives me only that one icon. In the snippet, I'm loading it using LR_LOADFROMFILE, but turning the icon into a resource and then loading it by ordinal or name – using either LoadImageA or LoadIconA – gives me the exact same result, and the same thing happens with other icons too. Obviously, IDA is not written in assembly, but is it possible that, when ida64.exe is run, the icon is loaded in some other way?
HSE, I am going by what kkurkiewicz posted. He is resizing a 128x128 icon from ida
down to 32x32, please reread his posts. :smiley:
Quote from: kkurkiewicz on September 14, 2023, 06:17:31 PMusing either LoadImageA or LoadIconA
Kamil,
You are on the right track:
- create a static control with the SS_ICON style
- in your resource file, use
77 ICON "Ida.ico"- use
invoke SendMessage, hMyStatic, STM_SETIMAGE, IMAGE_ICON, rv(LoadImage, hInstance, 77, IMAGE_ICON, 0, 0, 0) where 77 is the resource ID
LoadIcon looks simpler but you get an awfully pixelated result - no good.
I can assure you that the QT framework is not needed :cool:
Quote from: zedd151 on September 15, 2023, 09:55:13 AMHe is resizing a 128x128 icon from ida down to 32x32
That is what you think. But under the hood, Windows API make other thing. I presume that depend on system, system configuration and manifest.
Quote from: HSE on September 15, 2023, 11:07:38 PMQuote from: zedd151 on September 15, 2023, 09:55:13 AMHe is resizing a 128x128 icon from ida down to 32x32
That is what you think. But under the hood, Windows API make other thing. I presume that depend on system, system configuration and manifest.
No, that's what is
actually happening, obviously: there's a 128x128 icon (confirmed by OP) that's being displayed at 32x32 (also confirmed), so what Zedd wrote is true.
The question is, just
how is this being accomplished? That's open to speculation at this point.
Kamil problem is that 128x128 is scale down to 16x16. That is not strange because each window class store 2 icon copies, apparently one small to show in window corner, and one big to show in system bar. Because Kamil system show windows title bar bigger, small icon is scale up to 32x32.
But that it's not so simple. In my system (building template Masm32 SDK GUI apps) both windows class icons are 32x32. We don't know Kamil system, configurations, manifest, windows options... just something is different.
Quote from: HSE on September 16, 2023, 04:50:41 AMKamil problem is that 128x128 is scale down to 16x16. That is not strange because each window class store 2 icon copies, apparently one small to show in window corner, and one big to show in system bar. Because Kamil system show windows title bar bigger, small icon is scale up to 32x32.
Except that this does
not seem to be the case for the icon displayed by IDA (see the first post in this thread (https://masm32.com/board/index.php?msg=123829)), which is 32x32,
apparently scaled down from 128x128. Just look at those two icons: the one he's trying to show is much clearer than his 32x32 one, which may well be scaled up from 16x16 as you describe. But the other one is certainly sharper, therefore (I'm assuming) it's scaled down (by some process unknown to me) from 128x128--> 32x32.
Or I could be completely full of it, and willing to be proven wrong. But it seems to me that this is what's going on.
Quote from: NoCforMe on September 16, 2023, 04:57:24 AMOr I could be completely full of it, and willing to be proven wrong. But it seems to me that this is what's going on.
:biggrin: :biggrin:
IDA don't show window class icon in the corner. What you see is an specific "icon" Qt class .
Quote from: HSE on September 16, 2023, 05:23:40 AMIDA don't show window class icon in the corner. What you see is an specific "icon" Qt class .
So how do you know that? Not disputing you, mind you, just wondering where that knowledge comes from. (And I know nothing about Qt.)
Quote from: jj2007 on September 15, 2023, 10:44:04 AM- create a static control with the SS_ICON style
- in your resource file, use 77 ICON "Ida.ico"
- use invoke SendMessage, hMyStatic, STM_SETIMAGE, IMAGE_ICON, rv(LoadImage, hInstance, 77, IMAGE_ICON, 0, 0, 0) where 77 is the resource ID
Attached a testbed for you, a pure Masm32 SDK source :cool:
The icon in the upper left is displayed with DrawIcon.
The icon in the lower left is actually a bmp file.
Only the one in the right looks good - on a static control, as shown above.
Hard to tell at the size you posted, but both lower images look pretty good (and identical) to me.
Quote from: kkurkiewicz on September 14, 2023, 06:26:03 PMQuote from: NoCforMe on September 14, 2023, 11:30:47 AMWhat is the actual (displayed) size of that icon you show?
As far as I recall, the displayed size is 32x32.
I just checked some other icon, and it turns out that the actual size of the 'caption' icon displayed in the title bar might not be 32x32, but 28x28:
(https://i.postimg.cc/vgk727dS/ico1.png) (https://postimg.cc/vgk727dS)
The icon is 32px, but, when rendered, the size changes to 28x28. This one seems to endure the loading process much better than Ida's head but it clearly shows that even if the icon has the proper size, Windows will still somehow transform it.
Quote from: NoCforMe on September 16, 2023, 07:12:11 AMHard to tell at the size you posted, but both lower images look pretty good (and identical) to me.
Indeed, the only difference is transparency.
(https://masm32.com/board/index.php?action=dlattach;attach=16166;image)
Attached 40 lines of pure Masm32 code showing which is by far the best API to draw a 128x128 icon :biggrin:
Quote from: kkurkiewicz on September 16, 2023, 07:47:52 AMThe icon is 32px, but, when rendered, the size changes to 28x28.
I mean, the original icon fills the whole grid (there are no margins), so it seems like Windows is down-scaling the image to 28px only to add some kind of a frame there.
Quote from: NoCforMe on September 16, 2023, 05:33:55 AMSo how do you know that? Not disputing you, mind you, just wondering where that knowledge comes from.
Just using Spy (or similar tools) it's posible to see a lot of things at runtime. Anyway, a lot of speculation, not knowledge.
Quote from: NoCforMe on September 16, 2023, 05:33:55 AMAnd I know nothing about Qt.
It's some kind of language-script, that use a library of very big classes (or objects). Then result is an incredible bloated binary. In theory this library make very easy programmation, but I don't know either.
Quote from: kkurkiewicz on September 16, 2023, 08:01:02 AMI mean, the original icon fills the whole grid (there are no margins), so it seems like Windows is down-scaling the image to 28px only to add some kind of a frame there.
Ok :thumbsup:
Are you using Win11?
Ok. I's posible some different default scaling. Anyway look like a system feature. Bad luck 28x28 look ugly.
Perhaps only reliable solution is owner drawing title bar, like in ObjAsm's SkinApp or Fearless' ModernUI. Apparently that is what IDA make with Qt classes.
Yeah, I'll try that.
If I ever make it look better, I will let you know. Thank you for all the suggestions.