-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib
- Loading branch information
Showing
48 changed files
with
117,736 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
custom: ['https://www.paypal.me/MariusSucan/5'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# AHK GDI+ LIBRARY (extended compilation) | ||
|
||
This is a compilation of user contributed functions for the GDI+ library wrapper made by Tariq Porter [tic] that never made it into. | ||
|
||
This repository is a fork of https://github.com/mmikeww/AHKv2-Gdip/ . | ||
|
||
The compilation comes into two flavours: AHK v1.1 and AHK v2 compatible editions. | ||
|
||
The Gdip_all.ahk file for AHK v1.1 should be compatible with projects already relying on the original edition. In other words, it is backwards compatible. If you find this is not the case, please report the issue[s]. | ||
|
||
The original examples From TIC are in «examples-ahk-v1-1» folder. You can find several new examples that showcase the newly supported GDI+ APIs. These are example scripts initially provided by those that coded the new functions, with minor modifications. | ||
|
||
The examples for the AHK v2 edition I provide here in the repository were tested with AHK v2 alpha 108. In future versions of AHK v2, things might break. The library was not entirely tested on AHK v2. Therefore, bugs are likely present. Please provide feedback and/or pull requests to fix bugs. | ||
|
||
# History | ||
- @tic created the original [Gdip.ahk](https://github.com/tariqporter/Gdip/) library | ||
- @Rseding91 updated it to make it compatible with unicode and x64 AHK versions and renamed the file `Gdip_All.ahk` | ||
- @mmikeww's repository updates @Rseding91's `Gdip_All.ahk` to make it compatible with AHK v2 and also fixes some bugs | ||
- this repository attempts to gather all the GDI+ functions contributed by various people that were missing, and further extend the coverage/support of GDI+ API functions | ||
- MCL created an object-based GDI+ wrapper for AHK v1.1 that covers even more GDI+ functions; repository available at: https://github.com/mcl-on-github/oGdip.ahk | ||
|
||
# FUNCTIONS LIST | ||
|
||
- 42 GraphicsPath object functions | ||
- 43 Pen object functions | ||
- 29 PathGradient brush functions | ||
- 21 LinearGradient brush functions | ||
- 11 Texture brush functions | ||
- 10 SolidFill and hatch brush functions | ||
- 61 pBitmap functions | ||
- 16 ImageAttributes and Effects functions | ||
- 46 Fonts and StringFormat functions | ||
- 44 pGraphics functions | ||
- 24 Region functions | ||
- 11 Clip functions | ||
- 17 Transformation Matrix functions | ||
- 41 Draw/Fill on pGraphics functions | ||
- 14 GDI functions [selection]; the repository includes a GDI specialized library wrapper for AHK v1.1 that covers over 100 GDI functions | ||
- 23 Other functions [selection] | ||
|
||
Please see functions-list.txt for the actual list of functions. | ||
|
||
# COMPARISIONS | ||
|
||
The following list is comparing Gdip_All.ahk by Tariq Porter and Rseding91 modifications with this new version. | ||
|
||
## ~24 MODIFIED FUNCTIONS | ||
|
||
## ~300 NEW FUNCTIONS | ||
|
||
See functions-list.txt for more details and credits. | ||
|
||
## NOTES: | ||
- GetProperty() functions can yield incorrect results for some meta-data/properties. | ||
- awaiting pull requests for bug fixes | ||
|
||
## Derniere mise à jour: mardi 22 août 2023 [ 22/06/2023 ], v1.96 |
95 changes: 95 additions & 0 deletions
95
Lib/AHK-GDIp-Library-Compilation/ahk-v1-1/Examples-ahk-v1-1/Gdip.Tutorial.1-Draw.Shapes.ahk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
; gdi+ ahk tutorial 1 written by tic (Tariq Porter) | ||
; Requires Gdip.ahk either in your Lib folder as standard library or using #Include | ||
; | ||
; Tutorial to draw a single ellipse and rectangle to the screen | ||
|
||
#SingleInstance Force | ||
#NoEnv | ||
SetBatchLines -1 | ||
|
||
; Uncomment if Gdip.ahk is not in your standard library | ||
#Include ../Gdip_All.ahk | ||
|
||
; Start gdi+ | ||
If !pToken := Gdip_Startup() | ||
{ | ||
MsgBox "Gdiplus failed to start. Please ensure you have gdiplus on your system" | ||
ExitApp | ||
} | ||
OnExit("ExitFunc") | ||
|
||
; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap | ||
Width :=1400, Height := 1050 | ||
|
||
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption | ||
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs | ||
Gui, 1: Show, NA | ||
|
||
; Get a handle to this window we have created in order to update it later | ||
hwnd1 := WinExist() | ||
|
||
; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything | ||
hbm := CreateDIBSection(Width, Height) | ||
|
||
; Get a device context compatible with the screen | ||
hdc := CreateCompatibleDC() | ||
|
||
; Select the bitmap into the device context | ||
obm := SelectObject(hdc, hbm) | ||
|
||
; Get a pointer to the graphics of the bitmap, for use with drawing functions | ||
G := Gdip_GraphicsFromHDC(hdc) | ||
|
||
; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling) | ||
Gdip_SetSmoothingMode(G, 4) | ||
|
||
; Create a fully opaque red brush (ARGB = Transparency, red, green, blue) to draw a circle | ||
pBrush := Gdip_BrushCreateSolid(0xffff0000) | ||
|
||
; Fill the graphics of the bitmap with an ellipse using the brush created | ||
; Filling from coordinates (100,50) an ellipse of 200x300 | ||
Gdip_FillEllipse(G, pBrush, 100, 500, 200, 300) | ||
|
||
; Delete the brush as it is no longer needed and wastes memory | ||
Gdip_DeleteBrush(pBrush) | ||
|
||
; Create a slightly transparent (66) blue brush (ARGB = Transparency, red, green, blue) to draw a rectangle | ||
pBrush := Gdip_BrushCreateSolid(0x660000ff) | ||
|
||
; Fill the graphics of the bitmap with a rectangle using the brush created | ||
; Filling from coordinates (250,80) a rectangle of 300x200 | ||
Gdip_FillRectangle(G, pBrush, 250, 80, 300, 200) | ||
|
||
; Delete the brush as it is no longer needed and wastes memory | ||
Gdip_DeleteBrush(pBrush) | ||
|
||
|
||
; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen | ||
; So this will position our gui at (0,0) with the Width and Height specified earlier | ||
UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height) | ||
|
||
|
||
; Select the object back into the hdc | ||
SelectObject(hdc, obm) | ||
|
||
; Now the bitmap may be deleted | ||
DeleteObject(hbm) | ||
|
||
; Also the device context related to the bitmap may be deleted | ||
DeleteDC(hdc) | ||
|
||
; The graphics may now be deleted | ||
Gdip_DeleteGraphics(G) | ||
Return | ||
|
||
;####################################################################### | ||
|
||
ExitFunc(ExitReason, ExitCode) { | ||
global | ||
; gdi+ may now be shutdown on exiting the program | ||
Gdip_Shutdown(pToken) | ||
} | ||
|
||
~Esc:: | ||
ExitApp | ||
Return |
160 changes: 160 additions & 0 deletions
160
...ompilation/ahk-v1-1/Examples-ahk-v1-1/Gdip.Tutorial.10-Rotate.Flip.or.Mirror.an.image.ahk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
; gdi+ ahk tutorial 10 written by tic (Tariq Porter) | ||
; Requires Gdip.ahk either in your Lib folder as standard library or using #Include | ||
; | ||
; Tutorial to rotate, flip or mirror an image | ||
|
||
#SingleInstance Force | ||
#NoEnv | ||
SetBatchLines -1 | ||
|
||
; Uncomment if Gdip.ahk is not in your standard library | ||
#Include ../Gdip_All.ahk | ||
|
||
; Start gdi+ | ||
If !pToken := Gdip_Startup() | ||
{ | ||
MsgBox "Gdiplus failed to start. Please ensure you have gdiplus on your system" | ||
ExitApp | ||
} | ||
OnExit("ExitFunc") | ||
|
||
; Gui 1 | ||
; Create a gui where we can select the file we want to rotate, the angle to rotate it by and whether we want to flip it | ||
; Here is the slider allowing rotation between 0 and 360 degrees | ||
; Create 2 checkboxes, to select whether we want to flip it horizontally or vertically | ||
; Gui 2 | ||
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption | ||
; This will be used as the 2nd gui so that we can show our image on it | ||
|
||
Gui, 1: +ToolWindow +AlwaysOnTop | ||
Gui, 1: Add, Edit, x10 y10 w300 r1 vFile, %A_ScriptDir%\MJ.jpg | ||
Gui, 1: Add, Button, x+10 yp+0 w75 gGo Default, &Go | ||
Gui, 1: Add, Slider, x10 y+10 w300 Tooltip vAngle Range0-360, 0 | ||
Gui, 1: Add, CheckBox, x+10 yp+0 vHorizontal, Flip horizontally | ||
Gui, 1: Add, CheckBox, x+10 yp+0 vVertical, Flip vertically | ||
Gui, 1: Show, x0 y0 AutoSize | ||
Gui, 2: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs | ||
Gui, 2: Show, NA | ||
|
||
|
||
; Get a handle to this window we have created in order to update it later | ||
global hwnd2 := WinExist() | ||
|
||
; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui. This can be used for dragging the image | ||
OnMessage(0x201, "WM_LBUTTONDOWN") | ||
Return | ||
|
||
;##################################################################### | ||
|
||
ButtonGo_Click(GuiCtrlObj, Info) | ||
{ | ||
; Submit the variables to see the degress to rotate by and whether to flip the image | ||
global File, Angle, Horizontal, Vertical | ||
Go: ; this label is ok inside the func as long as the vars above are global | ||
Gui, 1: +OwnDialogs | ||
Gui, 1: Submit, NoHide | ||
|
||
; If the file in the edit field is not a valid image then return | ||
If !pBitmap := Gdip_CreateBitmapFromFile(File) | ||
Return | ||
|
||
; We should get the width and height of the image, in case it is too big for the screen then we can resize it to fit nicely | ||
OriginalWidth := Gdip_GetImageWidth(pBitmap), OriginalHeight := Gdip_GetImageHeight(pBitmap) | ||
Ratio := OriginalWidth/OriginalHeight | ||
|
||
; If the image has a width larger than 1/2 of the width of the screen or height larger than 1/2 the screen, then we will resize it to be half of the screen | ||
If (OriginalWidth >= A_ScreenWidth//2) || (OriginalHeight >= A_ScreenHeight//2) | ||
{ | ||
If (OriginalWidth >= OriginalHeight) | ||
Width := A_ScreenWidth//2, Height := Width*(1/Ratio) | ||
Else | ||
Height := A_ScreenHeight//2, Width := Height*Ratio | ||
} | ||
Else | ||
Width := OriginalWidth, Height := OriginalHeight | ||
|
||
; Width and Height now contain the new dimensions the image on screen will be | ||
|
||
; When rotating a square image, then the bitmap or canvas will need to be bigger as you can imagine that once rotated then a triangle will be wider than a square | ||
; We need to know the new dimensions of the image | ||
; With Gdip_GetRotatedDimensions we can plug in the width and height of the image, and the angle it is to be rotated by | ||
; The last 2 parameters are the variables in which tio store the new width and height of the rotated image | ||
; RWidth and RHeight now contain the dimensions of the rotated image | ||
Gdip_GetRotatedDimensions(Width, Height, Angle, RWidth, RHeight) | ||
|
||
; We rotate an image about the top left corner of the image, however this will result in the image moving off the canvas | ||
; We can use Gdip_GetRotatedTranslation to find how much the image should be 'shifted' by in the x and y coordinates in order for it to be back on the canvas | ||
; As with the above function, we plug in the width, height and angle to rotate by | ||
; The function will then make the last 2 parameters the x and y translation (this is the distance in pixels the image must be shifted by) | ||
; xTranslation and yTranslation now contain the distance to shift the image by | ||
Gdip_GetRotatedTranslation(Width, Height, Angle, xTranslation, yTranslation) | ||
|
||
; We will now create a gdi bitmap to display the rotated image on the screen (as mentioned previously we must use a gdi bitmap to display things on the screen) | ||
hbm := CreateDIBSection(RWidth, RHeight) | ||
|
||
; Get a device context compatible with the screen | ||
hdc := CreateCompatibleDC() | ||
|
||
; Select the bitmap into the device context | ||
obm := SelectObject(hdc, hbm) | ||
|
||
; Get a pointer to the graphics of the bitmap, for use with drawing functions, | ||
; and set the InterpolationMode to HighQualityBicubic = 7 so that when resizing the image still looks good | ||
G := Gdip_GraphicsFromHDC(hdc), Gdip_SetInterpolationMode(G, 7) | ||
|
||
; We can now shift our graphics or 'canvas' using the values found with Gdip_GetRotatedTranslation so that the image will be drawn on the canvas | ||
Gdip_TranslateWorldTransform(G, xTranslation, yTranslation) | ||
|
||
; We can also rotate the graphics by the angle we desire | ||
Gdip_RotateWorldTransform(G, Angle) | ||
|
||
; If we wish to flip the image horizontally, then we supply Gdip_ScaleWorldTransform(G, x, y) with a negative x transform | ||
; We multiply the image by the x and y transform. So multiplying a direction by -1 will flip it in that direction and 1 will do nothing | ||
; We must then shift the graphics again to ensure the image will be within the 'canvas' | ||
; You can see that if we wish to flip vertically we supply a negative y transform | ||
If Horizontal | ||
Gdip_ScaleWorldTransform(G, -1, 1), Gdip_TranslateWorldTransform(G, -Width, 0) | ||
If Vertical | ||
Gdip_ScaleWorldTransform(G, 1, -1), Gdip_TranslateWorldTransform(G, 0, -Height) | ||
|
||
|
||
; As you will already know....we must draw the image onto the graphics. We want to draw from the top left coordinates of the image (0, 0) to the top left of the graphics (0, 0) | ||
; We are drawing from the orginal image size to the new size (this may not be different if the image was not larger than half the screen) | ||
Gdip_DrawImage(G, pBitmap, 0, 0, Width, Height, 0, 0, OriginalWidth, OriginalHeight) | ||
|
||
; Even though this is not necessary in this scenario, you should always reset the transforms set on the graphics. This will remove any of the rotations | ||
Gdip_ResetWorldTransform(G) | ||
|
||
; We will update the hwnd with the hdc of our gdi bitmap. We are drawing it at the new width and height and in the centre of the screen | ||
UpdateLayeredWindow(hwnd2, hdc, (A_ScreenWidth-RWidth)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight) | ||
|
||
; As always we will dispose of everything we created | ||
; So we select the object back into the hdc, the delete the bitmap and hdc | ||
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc) | ||
; We will then dispose of the graphics and bitmap we created | ||
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap) | ||
Return | ||
} | ||
|
||
;##################################################################### | ||
|
||
; This is the function to allow the user to drag the image drawn on the screen (this being gui 2) | ||
WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) | ||
{ | ||
If (A_Gui = 2) | ||
PostMessage 0xA1, 2 | ||
} | ||
|
||
;##################################################################### | ||
|
||
; If the user closes the gui or closes the program then we want to shut down gdi+ and exit the application | ||
GuiClose: | ||
ExitApp | ||
return | ||
|
||
ExitFunc(ExitReason, ExitCode) | ||
{ | ||
global | ||
Gdip_Shutdown(pToken) | ||
} | ||
|
Oops, something went wrong.