It's all good now.
Thanks a lot, GeekDude!
GDI+ standard library 1.45 by tic
Re: GDI+ standard library 1.45 by tic
I have begun to create Gdip library version 2
https://github.com/tariqporter/Gdip/blo ... /Gdip2.ahk
Original method names will be included for users that need more control. Commented lines demonstrate how to perform the same actions calling the methods explicitly rather than using the new object based library. Dispose methods are still included as disposal cannot always be left to garbage collection, for an example, creating thousands of different coloured brushes in a loop that will only be used once.
This is only compatible with AHK 1.1 - The version that is linked to on this website and not the legacy version of AHK. Suggestions are welcomed.
https://github.com/tariqporter/Gdip/blo ... /Gdip2.ahk
Original method names will be included for users that need more control. Commented lines demonstrate how to perform the same actions calling the methods explicitly rather than using the new object based library. Dispose methods are still included as disposal cannot always be left to garbage collection, for an example, creating thousands of different coloured brushes in a loop that will only be used once.
This is only compatible with AHK 1.1 - The version that is linked to on this website and not the legacy version of AHK. Suggestions are welcomed.
Re: GDI+ standard library 1.45 by tic
I suggest calling it AHK v1.1, not AHK_L
Re: GDI+ standard library 1.45 by tic
Changed in my post. I think it should be named AHK v2 really as it isn't a minor upgrade from the old AHK. Object support as one example is a large overhaulGeekDude wrote:I suggest calling it AHK v1.1, not AHK_L
Re: GDI+ standard library 1.45 by tic
AHK v1.1 is almost completely backwards compatible. AHK v2 is reserved for the new version in development that isn't backwards compatible. See: http://ahkscript.org/v2/v2-changes.htm
Re: GDI+ standard library 1.45 by tic
When the width or height parameters are omitted and the screen DPI is greater than 100% the function fails to update the window (though it returns success). I believe this is due to the function calling the wingetPos command which will return DPI scaled width and height values. If these width and height values are greater than those used when calling CreateDIBSection() the window will not be updated.
Try running this code with different screen DPIs.
Edit: I'm a moron. You just have to disable gui scaling (-DPIScale) when creating the GUI.
Try running this code with different screen DPIs.
Code: Select all
#SingleInstance, Force
#NoEnv
OnExit, Exit
pToken := Gdip_Startup()
x := y := 250
w := h := 300
msgbox % A_screenDPI
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 1: Show, NA x%x% y%y% w%w% h%h%
hwnd1 := WinExist()
hbm := CreateDIBSection(w, h)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
pBrush := Gdip_BrushCreateSolid(0xaa000000)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, w, h, 20)
Gdip_DeleteBrush(pBrush)
WinGetPos,,, GUIWidth, GUIHeight, ahk_id %hwnd1%
;***
UpdateLayeredWindow(hwnd1, hdc) ; works fine when DPI is 100%
; This works with all DPIs --> UpdateLayeredWindow(hwnd1, hdc,,, w, h)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
msgbox width: %GUIWidth%`nHeight: %GUIHeight%
Return
f1::ExitApp
Exit:
Gdip_Shutdown(pToken)
ExitApp
Return
Re: GDI+ standard library 1.45 by tic
Hi tic!
Could you please comment on how new GDIP will be different (besides syntax)?
Im not a programmer by any means, just AHK "user", so to speak. So I wonder how this "object-oriented-ness" of new GDIP version will look like, and if I should update my GDIP-based scripts (~3,000 lines) or keep using old GDIP...
Thanks again for your wonderful work!
Could you please comment on how new GDIP will be different (besides syntax)?
Im not a programmer by any means, just AHK "user", so to speak. So I wonder how this "object-oriented-ness" of new GDIP version will look like, and if I should update my GDIP-based scripts (~3,000 lines) or keep using old GDIP...
Thanks again for your wonderful work!
Re: GDI+ standard library 1.45 by tic
Hi serg
The new library will have a simpler syntax and with Object support we can now better manage our drawing, making it much simpler to concentrate on our actual program, and not worry so much about Gdip. A very simple example if you take Gdip2 from the github repo
https://github.com/tariqporter/Gdip
A rewritten example 1 to use this beta Gdip2:
Anyway....Overall this will greatly simplify your existing and new applications, which ensures fewer errors and allows you to concentrate on what's important.
The new library will have a simpler syntax and with Object support we can now better manage our drawing, making it much simpler to concentrate on our actual program, and not worry so much about Gdip. A very simple example if you take Gdip2 from the github repo
https://github.com/tariqporter/Gdip
A rewritten example 1 to use this beta Gdip2:
Code: Select all
#Persistent
#SingleInstance Force
;Start Gdip
gdip := new Gdip()
;Create Point and Size objects for positioning our window
point1 := new gdip.Point(0, 0)
size1 := new gdip.Size(1400, 1050)
;Create a Gdip Object. This will be for all the drawing we do, and to display on screen
obj1 := new gdip.Object(size1)
;Create a Gdip Window. We need to pass it a Point and Size object (Or can pass our drawing Object, to take its dimensions as below)
win1 := new gdip.Window(point1, obj1)
;Create a brush. Can accept ARGB or separated values as A, R, G, B
brush1 := new gdip.Brush(255, 255, 0, 0)
;Fill Ellipse by passing our brush, and then some spoof Point and Size objects.
;Could use: new gdip.Point(100, 500)
;new gdip.Size(200, 300)
obj1.FillEllipse(brush1, { X: 100, Y: 500 }, { Width: 200, Height: 300 })
brush2 := new gdip.Brush(102, 0, 0, 255)
obj1.FillRectangle(brush2, { X: 250, Y: 80 }, { Width: 300, Height: 200 })
;Update the window on the screen with everything we've just done
;Pass our drawing Object along with a Point
win1.Update(obj1, point1)
;Optionally dispose of our objects. They would automatically be deleted however
brush1.Dispose()
brush2.Dispose()
obj1.Dispose()
gdip.Dispose()
return
- Things to note are :
- Now all the objects we will use to draw are encapsulated in a single object.
- We use Point and Size objects to perform drawings and positioning, and in the instance of "single use" Size/Point objects, we can create dummy objects as shown in FillEllipse and FillRectangle above.
- We dispose of our objects, but this isn't necessary as they would be automatically disposed of by ahk when out of scope.
Anyway....Overall this will greatly simplify your existing and new applications, which ensures fewer errors and allows you to concentrate on what's important.
Re: GDI+ standard library 1.45 by tic
tic,
Thank you for such a detailed answer! Indeed, your new GDIP lib looks easier than the old one and more "elegant", so to speak.
I think it should be included in standard AHK package, with instructions, - any AHK newbie will do huge favor to him/herself by learning how to use this lib. And it fits nicely right into the AHK philosophy - super easy to learn and it gives so much functionality!
Keep on doing great work, tic! This GDIP project of yours is awesome!
Thank you for such a detailed answer! Indeed, your new GDIP lib looks easier than the old one and more "elegant", so to speak.
I think it should be included in standard AHK package, with instructions, - any AHK newbie will do huge favor to him/herself by learning how to use this lib. And it fits nicely right into the AHK philosophy - super easy to learn and it gives so much functionality!
Keep on doing great work, tic! This GDIP project of yours is awesome!
Re: GDI+ standard library 1.45 by tic
I am still working on the v2 Gdip beta library. There are still lots of changes to be made.
Download the repository from github and run
Gdip2.Beta-Test.4-Zoom.Player.ahk
Gdip github
Zip support is still in testing and will be replaced by machine code to improve seeking speed.
IcoMoon icons added
https://icomoon.io/#preview-free
There isn't any commenting yet, as this is still just a preview
Please give comments as they will be valuable going forward
Download the repository from github and run
Gdip2.Beta-Test.4-Zoom.Player.ahk
Gdip github
Zip support is still in testing and will be replaced by machine code to improve seeking speed.
IcoMoon icons added
https://icomoon.io/#preview-free
There isn't any commenting yet, as this is still just a preview
Please give comments as they will be valuable going forward
Re: GDI+ standard library 1.45 by tic
IcoMoon reminds me a lot of FontAwesome. https://fortawesome.github.io/Font-Awesome/
Re: GDI+ standard library 1.45 by tic
Hi there,
I was wondering if you can help me, i find gdip quite confusing as i am not a proficient programmer.
I am trying to crop an image i am searching with, can i use GDIP for that?
I had in mind something like this:
1) i use testimage.png, and would like to search the screen for a percentage of the horizontal of that image.
So if the testimage.png is 10x100, would like to be able to crop the image horizontally, say 60%, so i am only using the first 60 pixels in my imagesearch.
I presume i would need to save the saved testimage.png as a temporary image, example, temporarytestimage.png.
The cut off the last number of horizontal pixels, using gdip? So if i wanted to search only 60% i would cut the image by the last 40 pixals.
Then use the new temporarytestimage.png in the imagesearch
Then delete afterwards.
Is all my ramblings possible with GDIP?
Kindest Regards
Surreall
I was wondering if you can help me, i find gdip quite confusing as i am not a proficient programmer.
I am trying to crop an image i am searching with, can i use GDIP for that?
I had in mind something like this:
1) i use testimage.png, and would like to search the screen for a percentage of the horizontal of that image.
So if the testimage.png is 10x100, would like to be able to crop the image horizontally, say 60%, so i am only using the first 60 pixels in my imagesearch.
I presume i would need to save the saved testimage.png as a temporary image, example, temporarytestimage.png.
The cut off the last number of horizontal pixels, using gdip? So if i wanted to search only 60% i would cut the image by the last 40 pixals.
Then use the new temporarytestimage.png in the imagesearch
Then delete afterwards.
Is all my ramblings possible with GDIP?
Kindest Regards
Surreall
- Learning one
- Posts: 173
- Joined: 04 Oct 2013, 13:59
- Location: Croatia
- Contact:
Re: GDI+ standard library 1.45 by tic
I'm willing to partially help you; see Resize, Rotate, Crop, Clone bitmapSurreall wrote:... I am trying to crop an image ...
My Website • Join DropBox
Re: GDI+ standard library 1.45 by tic
That is absolutely awesome, thank you.Learning one wrote:I'm willing to partially help you; see Resize, Rotate, Crop, Clone bitmapSurreall wrote:... I am trying to crop an image ...
I will have a play with those tonight!
Re: GDI+ standard library 1.45 by tic
Learning one wrote:I'm willing to partially help you; see Resize, Rotate, Crop, Clone bitmapSurreall wrote:... I am trying to crop an image ...
THis is probably a really stupid question, but how do i load an image into the variable pbitmap?
if the image is in %A_ScriptDir%\images\test.png
I thought
pbitmap := %A_ScriptDir%\images\test.png, which obviously doesnt work.
Also, can i copy the output bitmap onto clipboard, so i can view the new image in paint?
Regards
Surreall
Re: GDI+ standard library 1.45 by tic
pBitmap := Gdip_CreateBitmapFromFile("images\test.png")pbitmap := %A_ScriptDir%\images\test.png, which obviously doesnt work.
Gdip_SetBitmapToClipboard(pBitmapAlso, can i copy the output bitmap onto clipboard, so i can view the new image in paint?
Re: GDI+ standard library 1.45 by tic
tic wrote:pBitmap := Gdip_CreateBitmapFromFile("images\test.png")pbitmap := %A_ScriptDir%\images\test.png, which obviously doesnt work.
Gdip_SetBitmapToClipboard(pBitmap)Also, can i copy the output bitmap onto clipboard, so i can view the new image in paint?
Thank you very much.
I am having a little issue, it keeps saying preview not available. For testing i am just using:
Code: Select all
pBitmap := Gdip_CreateBitmapFromFile("images\test.png")
Gdip_SetBitmapToClipboard(pBitmap)
I have this in my code,
Code: Select all
SetworkingDir %A_ScriptDir%
Am i missing something obvious?
Regards
Surreall
Re: GDI+ standard library 1.45 by tic
Please read the examples on the first page. You need to initialize Gdip:
pToken := Gdip_Startup()
pToken := Gdip_Startup()
Re: GDI+ standard library 1.45 by tic
I copied tutorial 10 exactly.
The first gui comes up, where i can browes to my image, then nothing else happens.
Press go and nothing.
Regards
Surreall
The first gui comes up, where i can browes to my image, then nothing else happens.
Press go and nothing.
Regards
Surreall
Re: GDI+ standard library 1.45 by tic
Make sure you are using the Gdip_All as that covers different versions of AHK
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 155 guests