Width limit for GDIP?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Width limit for GDIP?

Post by toralf » 06 Aug 2022, 17:33

Hi

Is there a limit on how much wide a bitmap/graphic can be for GDIP?
I have a very wide graphic. With a width of 31974 the drawing works great. But when I have a width of 37613 there is nothing shown anymore.
The hight is only a 10th of the width. Hence I assume the problem is due to the width.

Snippet from the code:

Code: Select all

  Gui, Add, Text, w%width% h%height% HwndhText
  WinSet Style, +0xE, % "ahk_id " hText 
  pbm := Gdip_CreateBitmap(width, height)
  pg := Gdip_GraphicsFromImage(pbm)
  
  [... a lot of drawing ...]
  
  hbm := Gdip_CreateHBITMAPFromBitmap(pbm)
  SetImage(hText, hbm)
ciao
toralf

toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Width limit for GDIP?

Post by toralf » 06 Aug 2022, 17:35

Or is it due to me using Unicode 32 bit AHK?

Edit: Nope, just ran the code with Unicode 64 bit AHK: same problem.
ciao
toralf

toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Width limit for GDIP?

Post by toralf » 06 Aug 2022, 18:03

The limit seems to be close to
width = 32767
Height = 3707
Width x height = 121,470,604 pixel

Any idea of where this limit is coming from?
ciao
toralf

toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Width limit for GDIP?

Post by toralf » 06 Aug 2022, 18:57

It seems that there is a limit of 32767 pixel
At least someone else found such a limit in 2006:
https://forums.codeguru.com/showthread.php?407837-GDI-Bitmap-size-limitation
ciao
toralf

toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Width limit for GDIP?

Post by toralf » 06 Aug 2022, 19:08

Someone else stated that it depends on available virtual memory.
And suggests to use WIC instead

https://stackoverflow.com/questions/29175585/what-is-the-maximum-resolution-of-c-sharp-net-bitmap
ciao
toralf

RussF
Posts: 1237
Joined: 05 Aug 2021, 06:36

Re: Width limit for GDIP?

Post by RussF » 07 Aug 2022, 11:23

The range for a signed (i.e. positive or negative) 16 bit integer is -32,768 to +32767. GDIP must be using them rather than unsigned (0 to +65535) for its variables. Don't know why since a width/height would typically not be negative - but that's probably the reason.

I don't see a way around it without rewriting/recompiling the GDIP library.

Russ

Post Reply

Return to “Ask for Help (v1)”