GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

Post your working scripts, libraries and tools.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

31 Mar 2021, 18:06

The old Gdip_all.ahk is now converted and ready for use for AHK v2 on the repo below.

I have converted both the original and the robodesign version. Both are on the repo with examples.

In case you get too frustrated with this "quickly converted lib", here's another one that might serve you better:

Thanks to user @buliasz: https://github.com/buliasz/AHKv2-Gdip

But that is not actually the main event!

============================================================================

The documentation of credits is on going, but I HAVE to thank a few people up front whose help made this lib possible.

Thanks to:
  • @tic for the original gdip.ahk
  • @Rseding91 for the original Unicode rewrite of tic's lib
  • @robodesign who answered MANY of my questions about the concepts behind GDI+. And for his work on his version of Gdip_all.ahk
  • @guest3456 (mmikeww?) for the AHK v2 a108 rewrite Gdip_all.ahk and examples. I learned a lot from those.
    I know a few others participated in this original project like just me, and @isahound
  • Thanks to @GeekDude for his work on gdi.ahk. I referenced this old lib a lot and I will continue to do so.
  • I have to thank @just me again for teaching me about structure byte alignment (way back when) which has got me to the point where I can understand much more of docs.microsoft.com documentation.
  • And as always thanks to @lexikos for AHK v2, and for taking the time to answer some of my (occasionally malformed) questions.
  • @neogna2 for pointing out an oversight that also lead to several other fixes for ahk v2 beta.3
============================================================================

I'm working on a new GDI lib that treats GDI like GDI+. Structured in a class, more interoperability of objects, the works.

The demo is easy. Just edit it, pick a file to load (the bigger the better) and resize the window. See how smooth it is :D

This is a work in progress. There is quite a bit more to come.

============================================================================
Updates
============================================================================

Download on :arrow: GitHub
Last edited by TheArkive on 03 Feb 2022, 05:55, edited 15 times in total.
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: GDI++ - class wrapper - 2021/04/01 - a129 - EXPERIMENT

01 Apr 2021, 01:14

just to clarify, the original AHK v1 "Gdip_All.ahk" was created by @Rseding91 as a unicode compatible update to tic's original Gdip.ahk.

my attempt here was simply to make a backward compatible version for both ahk v1 and v2, but it stalled with all the recent updates in v2. but that also included many other contributors as well.

its good to see someone continuing the work

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2021/04/01 - a129 - EXPERIMENT

01 Apr 2021, 03:33

Thanks @guest3456. OP updated.

EDIT: And the repo README.
ZeronoFreya
Posts: 16
Joined: 31 Jan 2015, 09:28

Re: GDI++ - class wrapper - 2021/06/21 - a137 - EXPERIMENT

13 Jul 2021, 08:14

How to load the exe icon?
Autohotkey2
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2021/06/21 - a137 - EXPERIMENT

13 Jul 2021, 08:42

ZeronoFreya wrote:
13 Jul 2021, 08:14
How to load the exe icon?
I apparently forgot to include handling of resource icons. Thanks for asking. I'll add this on my to-do list for fixing.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2021/06/21 - beta.1 - EXPERIMENT

25 Jul 2021, 05:39

2021/07/25
  • updated the old GDIP libs for beta.1
  • some bizzare oversights fixed in examples
  • improved a few examples that needed a cleaner exit
  • replaced BufferAlloc() with Buffer()
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: GDI++ - class wrapper - 2021/07/25 - beta.1 - EXPERIMENT

24 Jan 2022, 06:34

@TheArkive I think there is an error at
https://github.com/TheArkive/GDI_plus_plus_ahk/blob/master/old_gdip_stuff/mmikeww/Gdip_All.ahk#L2108
Change it from

Code: Select all

DllCall("GetObject", Ptr, hBitmap, "int", oi := Buffer(A_PtrSize = 8 ? 104 : 84, 0), Ptr, oi.ptr)
to

Code: Select all

oi := Buffer(A_PtrSize = 8 ? 104 : 84, 0)
DllCall("GetObject", Ptr, hBitmap, "int", oi.size, Ptr, oi.ptr)
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getobject#parameters
[in] c ... The number of bytes of information to be written to the buffer.
With that change applied this example script works. It takes a screenshot of the upper left screen corner, saves it as .png and puts it on the clipboard.

Code: Select all

#Include Gdip_All.ahk
;Area := x "|" y "|" w "|" h
Area := 0 "|" 0 "|" 400 "|" 400
SaveFile := A_ScriptDir "\" A_Now ".png"
pToken := Gdip_Startup()
Sleep(50)
pBitmap := Gdip_BitmapFromScreen(Area)
Gdip_SaveBitmapToFile(pBitmap, SaveFile)
Gdip_SetBitmapToClipboard(pBitmap)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
pToken := ""
ExitApp
Edit:
Your gdip_all.ahk version is (after this fix) the only one I found that is compatible with v2-beta3. It would help if you highlighted that more in the repo or even moved it to a repo of its own. Because the current "old_gdip_stuff" folder name might confuse someone to think it is outdated.

I get that the repo is primarily for your GDI++ class. But a working v2 gdip_all.ahk is good to have too. For example I wanted it when converting an old v1 script that used the v1 lib to v2 and while also wanting to make as few changes to the old code as possible.

One more thing. If the issues mentioned by helgef and malcev at viewtopic.php?p=312230#p312230 apply also to your gdip_all.ahk then that is worth mentioning in the readme and source.
User avatar
hoppfrosch
Posts: 443
Joined: 07 Oct 2013, 04:05
Location: Rhine-Maine-Area, Hesse, Germany
Contact:

Re: GDI++ - class wrapper - 2021/07/25 - beta.1 - EXPERIMENT

25 Jan 2022, 07:07

@neogna2 : as iseahound mentioned here, there is a GDI+ library (Gdip_All.ahk) compatible with the current AutoHotKey v2 beta 3:

https://github.com/buliasz/AHKv2-Gdip

Haven't tested or reviewed it ....
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2021/07/25 - beta.1 - EXPERIMENT

25 Jan 2022, 07:15

@neogna2
Sorry for the belated reply. I'll get to that.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2021/07/25 - beta.1 - EXPERIMENT

25 Jan 2022, 07:29

@hoppfrosch
Thanks for posting that link. I'll put that in the OP. That guy might be able to keep this lib up to date better than me.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

25 Jan 2022, 07:34

I'm finding several other issues now that I'm looking at this lib closer.

Several missing &VarRefs where Ptr* or Int* is used.

I will be posting an update on this today.

EDIT: Also found a few instances where &VarRef was used but there is no * or P to denote an output field in DllCall.

EDIT2: And finding some old instances of ahk v1 &var that were missed, mostly with buffer objects, converting to var.ptr
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

25 Jan 2022, 11:05

2022/01/25
  • updated mmikeww and robodesign Gdip_all.ahk
  • included fix pointed out by @neogna2
  • renamed example files
  • removed a lot of redundant code
  • fixed references from v1 &obj to obj.ptr
    All examples seem to work as intended
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: GDI++ - class wrapper - 2021/07/25 - beta.1 - EXPERIMENT

25 Jan 2022, 11:54

hoppfrosch wrote:
25 Jan 2022, 07:07
@neogna2 : as iseahound mentioned here, there is a GDI+ library (Gdip_All.ahk) compatible with the current AutoHotKey v2 beta 3: https://github.com/buliasz/AHKv2-Gdip
Thanks. Thanks also to TheArkive.

A general question: Does anyone have a link to the source for the embedded mcode? I mean these instances
x86 mcode starting with 558BEC83EC3
https://github.com/buliasz/AHKv2-Gdip/blob/master/Gdip_All.ahk#L2699
x64 mcode starting with 44894424184
https://github.com/buliasz/AHKv2-Gdip/blob/master/Gdip_All.ahk#L2725

The same mcode is in TheArkive's v2 version and in Tic's last v1 version

To keep things open source it would be good to distribute the mcode C++ source together with the AHK source.
Last edited by neogna2 on 25 Jan 2022, 11:58, edited 1 time in total.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

25 Jan 2022, 11:57

@neogna2
That's a good point. I'll try and find that.

Also, this is not my code. None of it is. All the contributors are listed in the OP, but all I did was convert to v2 and maintain.

Just don't want there to be any confusion ;)
neogna2
Posts: 586
Joined: 15 Sep 2016, 15:44

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

25 Jan 2022, 12:01

TheArkive wrote:
25 Jan 2022, 11:57
Also, this is not my code. None of it is. All the contributors are listed in the OP, but all I did was convert to v2 and maintain.
Yeah, me saying "TheArkive's version" is just a sloppy shorthand for "TheArkive's specific v2.beta3 compatibility update of v2 code by several people that in turn is a v2 port of v1 code by tic but also a lot of other people evolving over a decade and in 100+ forum pages full of posts" :D
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

25 Jan 2022, 12:02

lol that's fair ;)

i found the source for one of the mcode bits. I'll add the src code as a comment to keep everything in one place

EDIT:

@neogna2
The Gdip_all.ahk in the robodesign folder on my reop has the source code. I'm just copying that over to the mmikeww version for consistency.
Last edited by TheArkive on 25 Jan 2022, 12:20, edited 1 time in total.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

25 Jan 2022, 12:12

@neogna2
If you check my repo, both Gdip_all files have the src code now.

EDIT: As i understand it, this src code is the x86 and x64 version. I'll keep my eyes out for separate code.
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

26 Jan 2022, 13:49

I was looking for this, thanks!

I would also advice to update the examples to beta.3

Just:
Change GuiCreate( to Gui(
Change OnExit("ExitFunc") to OnExit(ExitFunc)

:think: Is there a main github for Gdip V2?
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

26 Jan 2022, 13:50

@AHK_user
Dude it's in the OP, and yes GuiCreate() was changed to Gui() (lol)
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GDI++ - class wrapper - 2022/01/25 - beta.3 - EXPERIMENT

26 Jan 2022, 14:01

to clarify, the reop you are asking about is in the OP.

This thread is my own silly project (GDI++) as well as the old libs updated for AHK v2 beta.3

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: burque505 and 12 guests