Page 1 of 23

GDI+ standard library 1.45 by tic

Posted: 23 Feb 2015, 17:32
by tic
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

Re: GDI+ standard library 1.45 by tic

Posted: 23 Feb 2015, 17:33
by tic
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

Re: GDI+ standard library 1.45 by tic

Posted: 23 Feb 2015, 18:12
by geek
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"?

Re: GDI+ standard library 1.45 by tic

Posted: 23 Feb 2015, 18:32
by joedf
Awesome.

Re: GDI+ standard library 1.45 by tic

Posted: 24 Feb 2015, 14:38
by tic
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.

Re: GDI+ standard library 1.45 by tic

Posted: 24 Feb 2015, 15:16
by tic
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() ?

Re: GDI+ standard library 1.45 by tic

Posted: 24 Feb 2015, 19:03
by geek

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.

Re: GDI+ standard library 1.45 by tic

Posted: 24 Feb 2015, 22:26
by lexikos
I suppose that you could model it after the GDI+ object model in .NET.

Re: GDI+ standard library 1.45 by tic

Posted: 25 Feb 2015, 03:52
by Soft
nice to see you here!

Gdip_All.ahk stopped working after updating Autohotkey

Posted: 02 Mar 2015, 11:09
by Pacsa
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

Re: GDI+ standard library 1.45 by tic

Posted: 02 Mar 2015, 11:14
by geek
Working here, as far as I can tell

Image

Re: GDI+ standard library 1.45 by tic

Posted: 02 Mar 2015, 11:21
by Pacsa
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.

Re: GDI+ standard library 1.45 by tic

Posted: 02 Mar 2015, 11:23
by geek
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?

Re: GDI+ standard library 1.45 by tic

Posted: 02 Mar 2015, 11:28
by Pacsa
Unicode 64-bit.

Re: GDI+ standard library 1.45 by tic

Posted: 02 Mar 2015, 11:29
by geek
Try using unicode 32 bit instead

Re: GDI+ standard library 1.45 by tic

Posted: 02 Mar 2015, 11:45
by Pacsa
Sadly, still the same. It is not working. I even tried the ansi version. Thanks though.

Re: GDI+ standard library 1.45 by tic

Posted: 02 Mar 2015, 15:42
by Pacsa
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.

Re: GDI+ standard library 1.45 by tic

Posted: 02 Mar 2015, 16:23
by geek
Maybe it's DPI related? I have my DPI set to the normal value of 96, what's your set to?

Re: GDI+ standard library 1.45 by tic

Posted: 03 Mar 2015, 03:56
by Pacsa
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.

Re: GDI+ standard library 1.45 by tic

Posted: 03 Mar 2015, 08:10
by geek
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