Here are more GDI+ functions which are not part of Tic's GDI+ standard library:
GraphicsPath usage example:
[functions] More GDI+ functions
- Learning one
- Posts: 173
- Joined: 04 Oct 2013, 13:59
- Location: Croatia
- Contact:
Re: [functions] More GDI+ functions
So where is the code?
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: [functions] More GDI+ functions
I think this post is just a continuation to the old threads on old forum. There is also the code.
-
- Posts: 934
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: [functions] More GDI+ functions
Updated to work with latest AHK v.1.1 and probably v2 as well .
The original example still works with these functions.
Best regards, Marius.
The original example still works with these functions.
Code: Select all
;#####################################################################################
; GraphicsPath functions added by Learning one
; updated on 14/08/2019 by Marius Șucan
;#####################################################################################
; Function Gdip_AddPathBeziers
; Description Adds a sequence of connected Bézier splines to the current figure of this path.
;
; pPath Pointer to the GraphicsPath
; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
;
; return status enumeration. 0 = success
; Notes The first spline is constructed from the first point through the fourth point in the array and uses the second and third points as control points. Each subsequent spline in the sequence needs exactly three more points: the ending point of the previous spline is used as the starting point, the next two points in the sequence are control points, and the third point is the ending point.
Gdip_AddPathBeziers(pPath, Points)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
Points := StrSplit(Points, "|")
VarSetCapacity(PointF, 8*Points.Length())
for eachPoint, Point in Points
{
Coord := StrSplit(Point, ",")
NumPut(Coord[1], PointF, 8*(A_Index-1), "float")
NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float")
}
return DllCall("gdiplus\GdipAddPathBeziers", Ptr, pPath, Ptr, &PointF, "int", Points.Length())
}
Gdip_AddPathBezier(pPath, x1, y1, x2, y2, x3, y3, x4, y4)
{
; Adds a Bézier spline to the current figure of this path
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipAddPathBezier", Ptr, pPath
, "float", x1, "float", y1, "float", x2, "float", y2
, "float", x3, "float", y3, "float", x4, "float", y4)
}
;#####################################################################################
; Function Gdip_AddPathLines
; Description Adds a sequence of connected lines to the current figure of this path.
;
; pPath Pointer to the GraphicsPath
; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
;
; return status enumeration. 0 = success
Gdip_AddPathLines(pPath, Points)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
Points := StrSplit(Points, "|")
VarSetCapacity(PointF, 8*Points.Length())
for eachPoint, Point in Points
{
Coord := StrSplit(Point, ",")
NumPut(Coord[1], PointF, 8*(A_Index-1), "float")
NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float")
}
return DllCall("gdiplus\GdipAddPathLine2", Ptr, pPath, Ptr, &PointF, "int", Points0)
}
Gdip_AddPathLine(pPath, x1, y1, x2, y2)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipAddPathLine", Ptr, pPath, "float", x1, "float", y1, "float", x2, "float", y2)
}
Gdip_AddPathArc(pPath, x, y, w, h, StartAngle, SweepAngle)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipAddPathArc", Ptr, pPath, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
}
Gdip_AddPathPie(pPath, x, y, w, h, StartAngle, SweepAngle)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipAddPathPie", Ptr, pPath, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
}
Gdip_StartPathFigure(pPath)
{
; Starts a new figure without closing the current figure. Subsequent points added to this path are added to the new figure.
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipStartPathFigure", Ptr, pPath)
}
Gdip_ClosePathFigure(pPath)
{
; Closes the current figure of this path.
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipClosePathFigure", Ptr, pPath)
}
;#####################################################################################
; Function Gdip_DrawPath
; Description draws a sequence of lines and curves defined by a GraphicsPath object
;
; pGraphics Pointer to the Graphics of a bitmap
; pPen Pointer to a pen
; pPath Pointer to a Path
;
; return status enumeration. 0 = success
Gdip_DrawPath(pGraphics, pPen, pPath)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipDrawPath", Ptr, pGraphics, Ptr, pPen, Ptr, pPath)
}
Gdip_WidenPath(pPath, pPen, Matrix:=0, Flatness:=1)
{
; Replaces this path with curves that enclose the area that is filled when this path is drawn by a specified pen. This method also flattens the path.
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipWidenPath", Ptr, pPath, "uint", pPen, Ptr, Matrix, "float", Flatness)
}
Gdip_ClonePath(pPath)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
Ptr2 := A_PtrSize ? "UPtr*" : "UInt*"
DllCall("gdiplus\GdipClonePath", Ptr, pPath, Ptr2, pPathClone)
return pPathClone
}
Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
-
- Posts: 1
- Joined: 05 Jan 2020, 22:23
Re: [functions] More GDI+ functions
Thank you very much! Your functions helped me out of a pit.
In case someone likes to RESIZE his BITMAP without BLUR: Look at ----Gdip_SetSmoothingMode---- and ----Gdip_SetInterpolationMode----.
Gdip_SetSmoothingMode(G2, 0) and Gdip_SetInterpolationMode(G2, 5) worked for me.
In case someone likes to RESIZE his BITMAP without BLUR: Look at ----Gdip_SetSmoothingMode---- and ----Gdip_SetInterpolationMode----.
Gdip_SetSmoothingMode(G2, 0) and Gdip_SetInterpolationMode(G2, 5) worked for me.
-
- Posts: 934
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: [functions] More GDI+ functions
My pleasure.
Please also check...
https://github.com/marius-sucan/AHK-GDIp-Library-Compilation
It's a gdip library compilation I created where I gathered all of the functions I found and implemented many more.
Best regards, Marius.
Please also check...
https://github.com/marius-sucan/AHK-GDIp-Library-Compilation
It's a gdip library compilation I created where I gathered all of the functions I found and implemented many more.
Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: gwarble and 212 guests