Page 1 of 1

LoadPicture() can not load 256x256 icons?

Posted: 23 May 2020, 03:10
by SKAN

Code: Select all

#NoEnv
#Warn
#SingleInstance, Force

; Trying to load Resource Index: 80 (Resource ID: 84) from imagesres.dll

hMod   := DllCall( "LoadLibraryEx", "Str","imageres.dll", "Ptr",0, "Int",0x2, "Ptr")
hIcon1 := DllCall("LoadImage", "Ptr",hMod, "Int",84, "Int",1, "Int",256, "Int",256, "Int",0, "Ptr")

hIcon2 := LoadPicture("imageres.dll", "Icon80 w256 h256", IT)

Gui, Add, Picture,,    % "HICON:" hIcon1
Gui, Add, Picture,x+m, % "HICON:" hIcon2

Gui, Show,, % A_OsVersion
Return
  • Image

    In Windows 10 LoadPicture() seems to load a 128x128 icon which isn't available in Windows 7

    Image

Re: LoadPicture() can not load 256x256 icons?

Posted: 23 May 2020, 04:15
by Xtra
I had same results.

Re: LoadPicture() can not load 256x256 icons?

Posted: 23 May 2020, 05:10
by just me
I thought this had been fixed already.

The byte-sized Width and Height fields of the ICONRESDIR structure contain 0 for 256*256 icons. So AHK's LoadPicture() (almost) always will not find icons of this size.

I'd call it a bug.

Re: LoadPicture() can not load 256x256 icons?

Posted: 23 May 2020, 05:54
by SKAN
just me wrote:I'd call it a bug.
Thanks. I'll move this to Bug Reports.

Re: LoadPicture() can not load 256x256 icons?

Posted: 23 May 2020, 06:09
by just me
Related:

Obscure GUI Picture-related bug

and

Code: Select all

; LoadIconWithScaleDown() -> docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconwithscaledown (Win Vista+)
DllCall("LoadIconWithScaleDown", "Ptr", HMOD, "Str", Icon, "Int", IW, "Int", IH, "PtrP", HICON2)

Re: LoadPicture() can not load 256x256 icons?

Posted: 23 May 2020, 06:20
by SKAN
just me wrote:The byte-sized Width and Height fields of the ICONRESDIR structure contain 0 for 256*256 icons. So AHK's LoadPicture() (almost) always will not find icons of this size.
I don't think the size is the problem, according to @lexikos ' old post:
https://autohotkey.com/board/topic/81288-why-256x256-icon-not-showing-in-gui/?p=516705

IIRC, XP had 256x256 uncompressed icons.. Then MS woke-up and used PNG compression in Vista to keep resources compact.
PNG format seems to be the problem here.

Re: LoadPicture() can not load 256x256 icons?

Posted: 23 May 2020, 06:22
by SKAN
just me wrote: Related:

Code: Select all

; LoadIconWithScaleDown() -> docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconwithscaledown (Win Vista+)
DllCall("LoadIconWithScaleDown", "Ptr", HMOD, "Str", Icon, "Int", IW, "Int", IH, "PtrP", HICON2)
Yes. Thanks. I saw that.. I had read many posts including that one.

LoadPicture() can not load 256x256 icons?

Posted: 23 May 2020, 06:44
by SKAN
I wrote:PNG format seems to be the problem here.
Okay.. 128x128 is also a PNG.. only 96x96 is a bitmap!

Spoiler