Direct2D

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
Onimuru
Posts: 107
Joined: 08 Sep 2018, 18:35
Contact:

Direct2D

Post by Onimuru » 05 Jun 2021, 18:52

Has anyone made an effort at wrapping Direct2D for use with ahk v2?

I'm particularly struggling to marry a D2D1 bitmap with a GDIp bitmap's pBits and then draw to a layered hWnd RenderTarget. Any help would be greatly appreciated.


User avatar
Onimuru
Posts: 107
Joined: 08 Sep 2018, 18:35
Contact:

Re: Direct2D

Post by Onimuru » 07 Jun 2021, 07:16

@malcev

Thank you, I've managed to piece that together already. I'm struggling with two things in particular:

1] How do I convert a GDIp bitmap such that when I lock it's bits, I can pass that to ID2D1Bitmap::CopyFromMemory
2] How do I construct D2D1_POINT_2F for use with https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawline? The parameters are structs but they don't take pointers, it makes no sense lol.

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Direct2D

Post by malcev » 07 Jun 2021, 07:34

I am currently not interested in ahk 2, but You may read here
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=63527

User avatar
Onimuru
Posts: 107
Joined: 08 Sep 2018, 18:35
Contact:

Re: Direct2D

Post by Onimuru » 07 Jun 2021, 07:56

Very well, thank you.

User avatar
Onimuru
Posts: 107
Joined: 08 Sep 2018, 18:35
Contact:

Re: Direct2D

Post by Onimuru » 09 Jun 2021, 07:17

Cloaker on the AHK Discord server solved this for me. Here is the working solution:

Code: Select all

DrawLine(x1, y1, x2, y2, brush, strokeWidth := 1.0, strokeStyle := 0) {
	point0 := Buffer(8)
	NumPut("Float", x1, "Float", y1, point0)

	point1 := Buffer(8)
	NumPut("Float", x2, "Float", y2, point1)

	ComCall(15, this.Ptr, "Double", NumGet(point0, "Double"), "Double", NumGet(point1, "Double"), "Ptr", brush, "Float", strokeWidth, "Ptr", strokeStyle, "Int")
}

Post Reply

Return to “Ask for Help (v2)”