GDI+ standard library 1.45 by tic

Post your working scripts, libraries and tools for AHK v1.1 and older
robodesign
Posts: 941
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: GDI+ standard library 1.45 by tic

21 Apr 2023, 04:29

Good to hear . Please update to v1.95. I fixed some bugs related to that.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
KruschenZ
Posts: 45
Joined: 20 Jan 2021, 07:05
Location: Germany (Rheinhessen)
Contact:

Re: GDI+ standard library 1.45 by tic

21 Apr 2023, 04:45

Hi @robodesign,

with 1.95 the previous issue is existing again.
(with the same example).

GreetingZ
KruschenZ
robodesign
Posts: 941
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: GDI+ standard library 1.45 by tic

21 Apr 2023, 05:06

KruschenZ wrote:
21 Apr 2023, 04:45
Hi @robodesign,

with 1.95 the previous issue is existing again.
(with the same example).

GreetingZ
KruschenZ
Interesting...

The problem is the following:
You are passing the brush as color. It is wrong. Pass it as userBrush, that parameter is the right way.

The initial creator of the GDI+ library uses this if condition: If !Gdip_DeleteBrush(Gdip_CloneBrush(Colour[2])) . It tests if it is a brush or not. It was wrong of him to do it this way.

It clones the supposed brush and deletes the brush. Now, on my system, cloning a brush that is non-existent causes a crash. So, i added extra-checks: if the string length is of 6 or 8, i consider it a color, not a brush [this is what i did in v1.95]. It seems the brush object handle iD has a string length of 6 or 8 :-).

I cannot have the library crash when users pass colour.

The solution in your case is, as i said, pass it as userBrush param.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
KruschenZ
Posts: 45
Joined: 20 Jan 2021, 07:05
Location: Germany (Rheinhessen)
Contact:

Re: GDI+ standard library 1.45 by tic

21 Apr 2023, 07:52

Hi @robodesign :-)

ah, okay, thank you for this info/hint.
it works perfectly with this.

GreetingZ
KruschenZ
Flowgun
Posts: 79
Joined: 25 Aug 2022, 09:42

Re: GDI+ standard library 1.45 by tic

25 Apr 2023, 07:11

Marius, your version of the library breaks compatibility with x64.
it always uses "UPtr" while x64 version uses "UInt" (among some other changes.

in an old library made by tic, you can find code like this:
A_PtrSize ? "UPtr" : "UInt"
this allows it to use UPtr or UInt depending on the bitness to be compatible with both versions.

I started updating my library to be compatible with x64 and I wanted to share it, but I realized that I was updating version 1.92, and I simply don't have the changelog necessary to update to your latest version.

It's a lot of work, but I guess it's better if you do it to have just one good source.
robodesign
Posts: 941
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: GDI+ standard library 1.45 by tic

25 Apr 2023, 07:37

Flowgun wrote:
25 Apr 2023, 07:11
Marius, your version of the library breaks compatibility with x64.
it always uses "UPtr" while x64 version uses "UInt" (among some other changes.

in an old library made by tic, you can find code like this:
A_PtrSize ? "UPtr" : "UInt"
this allows it to use UPtr or UInt depending on the bitness to be compatible with both versions.

I started updating my library to be compatible with x64 and I wanted to share it, but I realized that I was updating version 1.92, and I simply don't have the changelog necessary to update to your latest version.

It's a lot of work, but I guess it's better if you do it to have just one good source.
Absolutely Incorrect statements, dear.

Please read on ptr and uptr here :

https://www.autohotkey.com/docs/v1/lib/DllCall.htm#types

The original creator of the library developed it when ahk did not have ptr and uptr options, old ahk versions. Or he just wanted to keep it compatible with older ahk versions.

In addition to this , I'm working only on x64 and everything works. Nothing is broken.

The condition, on x64 and x32, A_PtrSize always yields uptr. The entire condition reads as: "If A_PtrSize is defined do uptr, if not uint."

A_PtrSize is 8 on x64 and 4 on x32. If you use old ahk version it's undefined, so it'll use uint.

Next time do your homework properly.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Flowgun
Posts: 79
Joined: 25 Aug 2022, 09:42

Re: GDI+ standard library 1.45 by tic

25 Apr 2023, 08:01

hmmm fair enough. it's just that I was having some problems with the library, and they disappeared when I updated a few functions to have that condition. I'll investigate the issue further.
robodesign
Posts: 941
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: GDI+ standard library 1.45 by tic

25 Apr 2023, 08:13

Flowgun wrote:
25 Apr 2023, 08:01
hmmm fair enough. it's just that I was having some problems with the library, and they disappeared when I updated a few functions to have that condition. I'll investigate the issue further.
If your investigations do point to an actual bug in my library, please do not hesitate to write back. But please make sure to provide a test case.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Flowgun
Posts: 79
Joined: 25 Aug 2022, 09:42

Re: GDI+ standard library 1.45 by tic

25 Apr 2023, 08:17

btw, I noticed that the library doesn't have "Gdip_CreateBitmapFromScan0" as a function. I needed it to read webp files. maybe there's something equivalent to use and it's just my noobness. otherwise, I recommend adding it to the library.
robodesign
Posts: 941
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: GDI+ standard library 1.45 by tic

25 Apr 2023, 08:25

Flowgun wrote:
25 Apr 2023, 08:17
btw, I noticed that the library doesn't have "Gdip_CreateBitmapFromScan0" as a function. I needed it to read webp files. maybe there's something equivalent to use and it's just my noobness. otherwise, I recommend adding it to the library.
The function CreateBitmapFromScan0 is already covered by create bitmap function. Use search in the ahk file.

Gdi+ doesn't support webp.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Flowgun
Posts: 79
Joined: 25 Aug 2022, 09:42

Re: GDI+ standard library 1.45 by tic

25 Apr 2023, 10:00

for Webp, I'm using Teadrinker's functions: viewtopic.php?t=66335
the "CreateBitmapFromScan0" that he is using doesn't default "Stride" to "0", but it does this calculation:

Code: Select all

         bpp := (PixelFormat & 0xFF00) >> 8
         Stride := ((Width * bpp + 31) & ~31) >> 3	
I don't know if it's safe modify the Gdip_CreateBitmap function within the library to also do that calculation instead of defaulting to zero, or if it's better to calculate it before the function and then pass it as an argument. All I know is that it is required in this use-case.

one of the problems I had was that I was shutting down pToken twice when jumping between functions, which crashes the script. In the past, I modified Gdip_Shutdown() to always load the gdiplus library in hmodule before shutting it down. This way, it always finds it and never crashes.
My current solution is to make pToken a super-Global, then, within functions, I do this:

Code: Select all

function(){
	Global pToken
	pTokenState := pToken
	   if !pTokenState
		pToken := Gdip_Startup()
	;;; gdip code goes here
	   if !pTokenState
		pToken := Gdip_ShutDown(pToken)
}
I still have a couple of problems when I updated to the latest library. I will look more into them before posting about them.
robodesign
Posts: 941
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: GDI+ standard library 1.45 by tic

25 Apr 2023, 10:37

He uses a library DLL to load the WebP.

libwebp32Url := "https://s3.amazonaws.com/resizer-dynamic-downloads/webp/0.5.2/x86/libwebp.dll"
libwebp64Url := "https://s3.amazonaws.com/resizer-dynamic-downloads/webp/0.5.2/x86_64/libwebp.dll"

That is not GDI+. Please do not go offtopic here.

GDI+ start-up must be run once: when the script begins. And when everything is ending: shutdown. Not after every function is executed.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
V0RT3X
Posts: 362
Joined: 20 May 2023, 21:59
Contact:

Re: GDI+ standard library 1.45 by tic

21 May 2023, 07:36

Hello and sorry for such a simple basic question, but if a script is created using GDI, do you also need GDI on other computers to run said script on different computers?
It seems full of features, but if unable to run scripts on computers that don't also have GDI then it becomes severely limiting for my uses. Hoping I'm wrong...
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: GDI+ standard library 1.45 by tic

21 May 2023, 09:17

@V0RT3X, afaik GDI and GDI+ (mind the difference) is part of Windows. Of course, you will need the GDI+ AutoHotkey library mentioned in this topic, or you simply put its relevant parts/functions (or the complete library) into your script file. Compiling to exe should also work, if your source code #includes the library.
User avatar
V0RT3X
Posts: 362
Joined: 20 May 2023, 21:59
Contact:

Re: GDI+ standard library 1.45 by tic

21 May 2023, 09:27

@gregster, thank you. That makes sense.
ssjkakaroto
Posts: 5
Joined: 09 Mar 2019, 07:56

Re: GDI+ standard library 1.45 by tic

21 Aug 2023, 11:08

Hello, are any of the changes made to Gdip_SaveBitmapToFile after 1.93 incompatible with Windows 7 x64?
I have a script that works perfectly with 1.93, outputting a bitmap file to the hard disk, but with 1.94, 1.94.1 and 1.95 it just creates an empty file.
robodesign
Posts: 941
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: GDI+ standard library 1.45 by tic

22 Aug 2023, 03:08

ssjkakaroto wrote:
21 Aug 2023, 11:08
Hello, are any of the changes made to Gdip_SaveBitmapToFile after 1.93 incompatible with Windows 7 x64?
I have a script that works perfectly with 1.93, outputting a bitmap file to the hard disk, but with 1.94, 1.94.1 and 1.95 it just creates an empty file.
Please provide me with more details. What parameters do you pass to the function? What format do you want to save and doesn't work?
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 941
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: GDI+ standard library 1.45 by tic

22 Aug 2023, 08:10

Hello!

After investigations, saving as BMP failed. I fixed the bug. I released v1.96.

Thank you for the report.

Link to repository:
https://github.com/marius-sucan/AHK-GDIp-Library-Compilation

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
ssjkakaroto
Posts: 5
Joined: 09 Mar 2019, 07:56

Re: GDI+ standard library 1.45 by tic

24 Aug 2023, 07:35

Sorry for the late reply. It's now working with 1.96, thank you for the fast fix!

The command was simple:

Code: Select all

Gdip_SaveBitmapToFile(Haystack, "haystack.bmp")
ewerybody
Posts: 18
Joined: 04 Nov 2016, 09:16
Contact:

Re: GDI+ standard library 1.45 by tic

26 Apr 2024, 16:37

Hello Gdip folks!
Say this 1.96 is not up to speed with the latest AHK 2.0.12 is it?
I see byref in there and VarSetCapacity which have been deprecated.
But is there a newer port? Or a better up-to-date lib? What should one use nowadays? 🤔
Cheers :
eRiC

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 116 guests