LoadPicture() can not load 256x256 icons?

Report problems with documented functionality
User avatar
SKAN
Posts: 514
Joined: 29 Sep 2013, 16:58

LoadPicture() can not load 256x256 icons?

23 May 2020, 03:10

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
My Scripts and Functions: tiny.cc/skan
User avatar
Xtra
Posts: 1685
Joined: 02 Oct 2015, 12:15

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

23 May 2020, 04:15

I had same results.
just me
Posts: 6972
Joined: 02 Oct 2013, 08:51
Location: Germany

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

23 May 2020, 05:10

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.
User avatar
SKAN
Posts: 514
Joined: 29 Sep 2013, 16:58

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

23 May 2020, 05:54

just me wrote:I'd call it a bug.
Thanks. I'll move this to Bug Reports.
My Scripts and Functions: tiny.cc/skan
just me
Posts: 6972
Joined: 02 Oct 2013, 08:51
Location: Germany

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

23 May 2020, 06:09

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)
User avatar
SKAN
Posts: 514
Joined: 29 Sep 2013, 16:58

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

23 May 2020, 06:20

[quote="just me"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.
[/quote]

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.
My Scripts and Functions: tiny.cc/skan
User avatar
SKAN
Posts: 514
Joined: 29 Sep 2013, 16:58

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

23 May 2020, 06:22

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.
My Scripts and Functions: tiny.cc/skan
User avatar
SKAN
Posts: 514
Joined: 29 Sep 2013, 16:58

LoadPicture() can not load 256x256 icons?

23 May 2020, 06:44

I wrote:PNG format seems to be the problem here.
Okay.. 128x128 is also a PNG.. only 96x96 is a bitmap!

Spoiler
My Scripts and Functions: tiny.cc/skan

Return to “Bug Reports”

Who is online

Users browsing this forum: dominicx and 9 guests