GDI+ standard library 1.45 by tic

Post your working scripts, libraries and tools for AHK v1.1 and older
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

GDI+ standard library 1.45 by tic

23 Feb 2015, 17:32

Download: Gdip_All.ahk ( reccomended library Version for all AHK Versions ( ANSI|Unicode, x64|x86 ) )
Older version
Full featured gdi+ library with examples by me tic (Tariq Porter)
Supports AHK and AHK_L

This library can be distributed for commercial and non-commercial use and I actively encourage both. I would appreciate it if people give acknowledgement for my work and would be nice to have pasted once at the top of your script something similar to:
Thanks to tic (Tariq Porter) for his GDI+ Library
ahkscript.org/boards/viewtopic.php?t=6517
or anything more elaborate if you feel like it!

A big thank you to Lexikos and Sean for their help and contributions

If your OS is not >= XP then you will need gdiplus.dll

A link to the original post as there is so much information contained in those 93 pages:

https://autohotkey.com/board/topic/2944 ... 45-by-tic/

Examples

Example 1: Gdip.Tutorial.1-Draw.Shapes.ahk - Create a simple gui and draw an ellipse and a rectangle

Example 2: Gdip.Tutorial.2-Draw.Outlined.Shapes.ahk - Create a simple gui and draw the outlines of an ellipse and a rectangle

Example 3: Gdip.Tutorial.3-Create.Gui.From.Image.ahk - Create a gui from an existing image on disk

Example 4: Gdip.Tutorial.4-Draw.Circles.ahk - Create a fullscreen gui and fill it with random ellipses

Example 5: Gdip.Tutorial.5-Create.Bitmap.ahk - Put a few shapes into a bitmap and save to a ".png" filetype

Example 6: Gdip.Tutorial.6-Image.Editing.ahk - Take files from disk, load them onto a background and save to a ".png" filetype

Example 7: Gdip.Tutorial.7-Draw.draggable.rounded.rectangle.ahk - Draw a rounded rectangle for a gui and allow it to be dragged with the left click of the mouse

Example 8: Gdip.Tutorial.8-Write.text.onto.a.gui.ahk - Take the rounded rectangle gui and add text to it, showing all the text options possible

Example 9: Gdip.Tutorial.9-Create.a.progress.bar.on.standard.gui.ahk - Create a nice looking progress bar using the library in a standard gui

Example 10: Gdip.Tutorial.10-Rotate.Flip.or.Mirror.an.image.ahk - Rotate, flip or mirror an image on a layered window

The BRA Library so far: BRA.ahk

Example 11: Gdip.Tutorial.11-Using.BRAs.to.perform.animations.ahk - Using BRA files to transport many images with your script and show animation
Please also download the BRA here: Gdip.tutorial.file-fish.bra

Example 12: Gdip.Tutorial.12-Pixelate.a.bitmap.using.machine.code - Use LockBits and machine code to pixelate an image and update it quickly
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

23 Feb 2015, 17:33

File links will be moved from autohotkey.com. Support will also be dropped for the old autohotkey, and library updated to take advantage of objects
geek
Posts: 1051
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: GDI+ standard library 1.45 by tic

23 Feb 2015, 18:12

Great to see you've moved it over here. Is there an ETA on any updates? Or is it more of a "I've planned it, but who knows if it'll ever get done"?
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: GDI+ standard library 1.45 by tic

23 Feb 2015, 18:32

Awesome.
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

24 Feb 2015, 14:38

GeekDude wrote:Great to see you've moved it over here. Is there an ETA on any updates? Or is it more of a "I've planned it, but who knows if it'll ever get done"?
Good question! I would like to be proactive and welcome any nudging every now and again to get me going.
I've taken the first 2 steps at least....I've created this post, and have now moved all the links to github, which will make changes much easier to track.

https://github.com/tariqporter/Gdip

Next step is to decide on the best way to treat gdi and gdi+ bitmaps and graphics and their associated handles/pointers as objects. I have an idea of how, but would need testing to see if it works comfortably in practice.
tic
Posts: 92
Joined: 03 Nov 2014, 03:10

Re: GDI+ standard library 1.45 by tic

24 Feb 2015, 15:16

As a proposed possibility, how does the following look?

Code: Select all

pToken := Gdip_Startup()

w := A_ScreenWidth, h := A_ScreenHeight
gui1 := Gdip_GuiCreate()
obj1 := Gdip_ObjectCreate(w, h)

brush1 := Gdip_BrushCreate(0xff00ff00)
obj1.FillEllipse(brush1, w/2, h/2, 50, 50)
gui1.Update(obj1, 0, 0, w, h)
brush1.Dispose()

obj1.Dispose()
Gdip_Shutdown(pToken)
return
It is not completely thought out, as I would need to consider how to handle gdi bitmaps for windows and gdi+ bitmaps for the file system, but if I get enough thoughts on this then I can begin work.

Any better naming than Gdip_ObjectCreate() ?
geek
Posts: 1051
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: GDI+ standard library 1.45 by tic

24 Feb 2015, 19:03

Code: Select all

obj1 := new Gdip.Object()
brush1 := new Gdip.Brush(0xFF00FF00)
etc

And dispose should probably be handled in __Delete if it was not called manually.
lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

Re: GDI+ standard library 1.45 by tic

24 Feb 2015, 22:26

I suppose that you could model it after the GDI+ object model in .NET.
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

Re: GDI+ standard library 1.45 by tic

25 Feb 2015, 03:52

nice to see you here!
AutoHotkey & AutoHotkey_H v1.1.22.07
Pacsa
Posts: 7
Joined: 02 Mar 2015, 11:02

Gdip_All.ahk stopped working after updating Autohotkey

02 Mar 2015, 11:09

Hi guys,
yesterday, I updated my AutoHotKey from 1.1.10.01 to 1.1.19.03 on my Win7 64bit machine. I had been using this script http://www.autohotkey.com/board/topic/6 ... /?p=662909 for quite a while without problems. Unfortunately it stopped working after the update. To be exact, it's still working in the background, but the clock itself doesn't appear on the screen any more. This is why I suspect that something is broken on the graphical side. That script was not written by me originally, I just added some non-graphics-related features, so I don't have much experience about how to go around with Gdip_All.ahk. Anyway, it was working fine with v1.1.10.01, and it is not working now. Btw, I also updated Gdip_All.ahk from the version at http://www.autohotkey.net/~Rseding91/Gd ... ip_All.ahk to the version shared in the first post of tic, which was updated last on 2/20/2014, but I experience the same. Do you have any ideas, what could be the reason? I also checked the recent changes in AutoHotKey, but I couldn't find a relevant change.
Your help is much appreciated.
Csaba
geek
Posts: 1051
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: GDI+ standard library 1.45 by tic

02 Mar 2015, 11:14

Working here, as far as I can tell

Image
Pacsa
Posts: 7
Joined: 02 Mar 2015, 11:02

Re: GDI+ standard library 1.45 by tic

02 Mar 2015, 11:21

I envy you. Are you using the most recent version of Autohotkey v1.1.19.03? Your operating system? Mine is Win7 Pro SP1 64-bit.
geek
Posts: 1051
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: GDI+ standard library 1.45 by tic

02 Mar 2015, 11:23

I'm using 1.1.19.03-22+g2609ddd (bleeding edge test build), on Win7 Pro SP1 32-bit. Are you using 32 or 64 bit AutoHotkey?
Pacsa
Posts: 7
Joined: 02 Mar 2015, 11:02

Re: GDI+ standard library 1.45 by tic

02 Mar 2015, 11:28

Unicode 64-bit.
geek
Posts: 1051
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: GDI+ standard library 1.45 by tic

02 Mar 2015, 11:29

Try using unicode 32 bit instead
Pacsa
Posts: 7
Joined: 02 Mar 2015, 11:02

Re: GDI+ standard library 1.45 by tic

02 Mar 2015, 11:45

Sadly, still the same. It is not working. I even tried the ansi version. Thanks though.
Pacsa
Posts: 7
Joined: 02 Mar 2015, 11:02

Re: GDI+ standard library 1.45 by tic

02 Mar 2015, 15:42

I downloaded the old version, and now I can run the script again, just as before. I tried some more recent ones, and it turned out that the clock is failing already with the next one: v1.1.11.00. I only tried the x64 versions. So it looks like the changes appearing first in v1.1.11.00 make the difference?..

And at the same time, it seems to affect only x64 machines? At least me, but as we see, GeekDude can run it on a 32 bit system, but for me it's not working even with the 32 bit executable.
geek
Posts: 1051
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: GDI+ standard library 1.45 by tic

02 Mar 2015, 16:23

Maybe it's DPI related? I have my DPI set to the normal value of 96, what's your set to?
Pacsa
Posts: 7
Joined: 02 Mar 2015, 11:02

Re: GDI+ standard library 1.45 by tic

03 Mar 2015, 03:56

Yes, indeed, it was the DPI. I was using the default 125% setting, now it's on 100%, and the script is working again. Thanks for the hint.
Nevertheless, I quite liked the 125% DPI. Is there a way the to return to that? The only thing I could think of was to disable the new feature by adding the line:
Gui -DPIScale
It didn't work. Right now I don't have the time to read all the relevant parts of the manual (of Autohotkey or the GDI+ library?), but I have the feeling that this feature was not meant to work this way.
geek
Posts: 1051
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: GDI+ standard library 1.45 by tic

03 Mar 2015, 08:10

I've updated the line UpdateLayeredWindow(hwnd1, hdc) to UpdateLayeredWindow(hwnd1, hdc, 0, 0, WinWidth, WinHeight) in this section here, and it seems to work on non-standard DPIs now:

Code: Select all

write_display_text_clock:
Gdip_SetCompositingMode(G, 1)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, WinWidth, WinHeight, 5)
Gdip_SetCompositingMode(G, 0)
Options = x0 y6 w140 %display_color% Center %display_size%
Gdip_TextToGraphics(G, displaytext, Options, Font, winWidth, winHeight)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, WinWidth, WinHeight)
return

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: sanmaodo, TheNaviator and 89 guests