I am updating my stdlib every day before i release it. heres an example of how to create a circle for a window:
Code:
#SingleInstance, Force
#NoEnv
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1
SetWinDelay, 0
SetWorkingDir %A_ScriptDir%
#Include Gdip.ahk ; Comment if you add it as part of your stdlib
pToken := Gdip_Startup() ; Start gdi+
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs ; Create a window
Gui, 1: Show, w1 h1 Hide
hwnd1 := WinExist() ; Get a handle to the window
hbm := CreateDIBSection(100, 100) ; Create a gdi bitmap (not gdi+) required for alphablended windows with width and height 100
hdc := DllCall("CreateCompatibleDC", "UInt", 0) ; Create compatible device context (dc)
obm := DllCall("SelectObject", "UInt", hdc, "UInt", hbm) ; Select the bitmap into the dc
G := Gdip_GraphicsFromHDC(hdc) ; Get a graphics context for the bitmap for "drawing functions"
Gdip_SmoothingMode(G, 4) ; Antialias smoothingmode for better looking pie
hBrush := Gdip_BrushCreateSolid(0xffff0000) ; Create a red fully opaque brush (ARGB)
Gdip_FillPie(G, hBrush, 0, 0, 100, 100, 0, 360) ; Draw a 360 degree pie (a circle) with diameter 100
UpdateLayeredWindow(hwnd1, hdc, 0, 0, 100, 100) ; Update the window with the handle to the dc of the bitmap
Gui, 1: Show, NA ; Show the window (only needs to be done once
;Cleanup
Gdip_DeleteBrush(hBrush)
Gdip_DeleteGraphics(G)
DllCall("SelectObject", "UInt", hdc, "UInt", obm)
DllCall("DeleteObject", "UInt", hbm)
DllCall("DeleteDC", "UInt", hdc)
Return
Let me know if you want more examples, such as saving this to a file etc...
and heres where im up to on the library:
Code:
; GDI and Object functions
; ########################
; UpdateLayeredWindow
; CreateRectF
; CreateSizeF
; CreateDIBSection
;#####################################################################################
;#####################################################################################
;
; GDI and Object functions
;
;#####################################################################################
;#####################################################################################
; Function: UpdateLayeredWindow
; Description: Updates a layered window with the handle to the DC of a bitmap
;
; hwnd = Handle of the window to update
; hdc = Handle to the DC of the GDI bitmap to update the window with
; Layeredx = x position to place the window
; Layeredy = x position to place the window
; Layeredw = Width of the window
; Layeredh = Height of the window
; Alpha = Default = 255 : The transparency (0-255) to set the window transparency
;
; Return: Returns the errorlevel of "UpdateLayeredWindow"
;
UpdateLayeredWindow(hwnd, hdc, Layeredx, Layeredy, Layeredw, Layeredh, Alpha=255)
{
VarSetCapacity(pt, 8), NumPut(LayeredX, pt, 0), NumPut(LayeredY, pt, 4)
E := DllCall("UpdateLayeredWindow"
, "UInt", hwnd
, "UInt", 0
, "UInt", &pt
, "Int64*", Layeredw|Layeredh<<32
, "UInt", hdc
, "Int64*", 0
, "UInt", 0
, "UInt*", Alpha<<16|1<<24
, "UInt", 2)
VarSetCapacity(pt, 0)
Return, E
}
;#####################################################################################
; Function: CreateRectF
; Description: Creates a RectF object, containing a the coordinates and dimensions of a rectangle
;
; RectF = Name to call the RectF object
; x = x-coordinate of the upper left corner of the rectangle
; y = y-coordinate of the upper left corner of the rectangle
; w = Width of the rectangle
; h = Height of the rectangle
;
; Return: No return value
;
CreateRectF(ByRef RectF, x, y, w, h)
{
VarSetCapacity(RectF, 16)
NumPut(x, RectF, 0, "Float"), NumPut(y, RectF, 4, "Float"), NumPut(w, RectF, 8, "Float"), NumPut(h, RectF, 12, "Float")
}
;#####################################################################################
; Function: CreateSizeF
; Description: Creates a SizeF object, containing an 2 values
;
; SizeF = Name to call the SizeF object
; w = w-value for the SizeF object
; h = h-value for the SizeF object
;
; Return: No Return value
;
CreateSizeF(ByRef SizeF, w, h)
{
VarSetCapacity(SizeF, 8)
NumPut(w, SizeF, 0, "Float"), NumPut(h, SizeF, 4, "Float")
}
;#####################################################################################
; Function: CreateDIBSection
; Description: Creates a SizeF object, containing an 2 values
;
; SizeF = Name to call the SizeF object
; w = w-value for the SizeF object
; h = h-value for the SizeF object
;
CreateDIBSection(w, h, bpp=32, hDC=0, ByRef ppvBits=0)
{
hdcUsed := hDC ? hDC : DllCall("GetDC", "UInt", 0)
If (hdcUsed)
{
VarSetCapacity(bi, 40, 0) ; BITMAPINFO(HEADER)
NumPut(40, bi, 0) ; biSize
NumPut(1, bi, 12, "UShort") ; biPlanes
NumPut(0, bi, 16) ; biCompression = BI_RGB (none)
NumPut(w, bi, 4) ; biWidth
NumPut(h, bi, 8) ; biHeight
NumPut(bpp,bi, 14, "UShort") ; biBitCount
hbm := DllCall("CreateDIBSection", "UInt" , hDC, "UInt" , &bi, "UInt" , 0, "UInt*", ppvBits, "UInt" , 0, "UInt" , 0)
DllCall("ReleaseDC", "UInt", 0, "UInt", hdcUsed)
VarSetCapacity(bi, 0)
Return, hbm
}
Return, 0
}
;#####################################################################################
DestroyIcon(hIcon)
{
Return, DllCall("DestroyIcon", "UInt", hIcon)
}
;#####################################################################################
;#####################################################################################
;
; Misc functions
;
;#####################################################################################
pBitmapFromBRA(ByRef BRAFromMemIn, File)
{
If (SubStr(File, 1, 4) = "File") && (SubStr(File, 5, StrLen(File)-4) & 1 != "")
{
RegExMatch(BRAFromMemIn, ":H:([0-9]+).*?:a:" SubStr(File, 5, StrLen(File)-4) ":b:(.*?):c:([0-9]+):d:([0-9]+)::", FileInfo)
File := FileInfo2
}
Else
RegExMatch(BRAFromMemIn, ":H:([0-9]+).*?:a:([0-9]+):b:\Q" File "\E:c:([0-9]+):d:([0-9]+)::", FileInfo)
;MsgBox, % FileInfo3 "`n" FileInfo1+FileInfo4 ;%
If !FileInfo
Return, 0
hData := DllCall("GlobalAlloc", "UInt", 2, "UInt", FileInfo3)
pData := DllCall("GlobalLock", "UInt", hData)
DllCall("RtlMoveMemory", "UInt", pData, "UInt", &BRAFromMemIn+FileInfo1+FileInfo4, "UInt", FileInfo3)
DllCall("GlobalUnlock", "UInt", hData)
DllCall("ole32\CreateStreamOnHGlobal", "UInt", hData, "Int", 1, "UInt*", pStream)
DllCall("gdiplus\GdipCreateBitmapFromStream", "UInt", pStream, "UInt*", pBitmap)
DllCall(NumGet(NumGet(1*pStream)+8), "UInt", pStream)
Return, pBitmap
}
TextToImage(pBitmap, Text, Options, Font)
{
IWidth := Gdip_GetImageWidth(pBitmap), IHeight:= Gdip_GetImageHeight(pBitmap)
If !(IWidth && IHeight)
Return, -1
RegExMatch(Options, "(X|x)([0-9]+)(p*)", xpos)
RegExMatch(Options, "(Y|y)([0-9]+)(p*)", ypos)
RegExMatch(Options, "(W|w)([0-9]+)(p*)", Width)
RegExMatch(Options, "(H|h)([0-9]+)(p*)", Height)
RegExMatch(Options, "(C|c)(?!(entre|enter))([a-fA-F0-9]+)", Colour) ;i)c[a-f\d]{8}\b
RegExMatch(Options, "(R|r)(?!(R|r)ight)([0-9])", Rendering)
RegExMatch(Options, "(S|s)([0-9]+)(p*)", Size)
Style := 0, Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout"
Loop, Parse, Styles, |
{
If InStr(Options, A_loopField)
Style |= (A_LoopField != "StrikeOut") ? (A_Index-1) : 8
}
Align := 0, Alignments := "Near|Left|Centre|Center|Far|Right"
Loop, Parse, Alignments, |
{
If InStr(Options, A_loopField)
Align |= A_Index//2.1 ; 0|0|1|1|2|2
}
xpos := (xpos2 != "") ? xpos3 ? IWidth*(xpos2/100) : xpos2 : IWidth//2
ypos := (ypos2 != "") ? ypos3 ? IHeight*(ypos2/100) : ypos2 : IHeight//2
Width := Width2 ? Width3 ? IWidth*(Width2/100) : Width2 : IWidth
Height := Height2 ? Height3 ? IHeight*(Height2/100) : Height2 : IHeight
Colour := "0x" ((StrLen(Colour3) = 8) ? Colour3 : "ff000000")
Rendering := ((Rendering2 >= 0) && (Rendering2 <= 4)) ? Rendering2 : 4
Size := (Size2 > 0) ? Size3 ? IHeight*(Size2/100) : Size2 : 15
pGraphics := Gdip_GraphicsFromImage(pBitmap)
hFamily := Gdip_FontFamilyCreate(Font)
hFont := Gdip_FontCreate(hFamily, Size, Style)
hFormat := Gdip_StringFormatCreate(0x4000)
hBrush := Gdip_BrushCreateSolid(Colour)
If !(hFamily && hFont && hFormat && hBrush && pGraphics)
Return, !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !hBrush ? -6 : 0
CreateRectF(RC, xpos, ypos, Width, Height)
Gdip_SetStringFormatAlign(hFormat, Align)
Gdip_SetTextRenderingHint(pGraphics, Rendering)
E1 := Gdip_DrawString(pGraphics, Text, hFont, hFormat, hBrush, RC)
E2 := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
VarSetCapacity(RC, 0)
Gdip_DeleteBrush(hBrush)
Gdip_DeleteStringFormat(hFormat)
Gdip_DeleteFont(hFont)
Gdip_DeleteFontFamily(hFamily)
Gdip_DeleteGraphics(pGraphics)
Return, E1 ? E1 : E2
}
;#####################################################################################
;
; GDI+ functions
;
;#####################################################################################
;#####################################################################################
;#####################################################################################
; Draw shape/line
;#####################################################################################
Gdip_DrawRectangle(pGraphics, hPen, x, y, w, h)
{
Return, DllCall("gdiplus\GdipDrawRectangle", "UInt", pGraphics, "UInt", hPen
, "Float", x, "Float", y, "Float", w, "Float", h)
}
Gdip_DrawBezier(pGraphics, hPen, x1, y1, x2, y2, x3, y3, x4, y4)
{
Return, DllCall("gdiplus\GdipDrawBezier", "UInt", pgraphics, "UInt", hPen
, "Float", x1, "Float", y1, "Float", x2, "Float", y2
, "Float", x3, "Float", y3, "Float", x4, "Float", y4)
}
GdiP_DrawArc(pGraphics, hPen, x, y, w, h, StartAngle, SweepAngle)
{
Return, DllCall("gdiplus\GdipDrawArc", "UInt", pGraphics, "UInt", hPen
, "Float", x, "Float", y, "Float", w, "Float", h, "Float", StartAngle, "Float", SweepAngle)
}
Gdip_DrawPie(pGraphics, hPen, x, y, w, h, StartAngle, SweepAngle)
{
Return, DllCall("gdiplus\GdipFillPie", "UInt", pGraphics, "UInt", hPen, "Float", x, "Float", y, "Float", w, "Float", h, "Float", StartAngle, "Float", SweepAngle)
}
Gdip_DrawLine(pGraphics, hPen, x1, y1, x2, y2)
{
Return, DllCall("gdiplus\GdipDrawLine", "UInt", pGraphics, "UInt", hPen
, "Float", x1, "Float", y1, "Float", x2, "Float", y2)
}
; Points passed as x1,y1|x2,y2|x3,y3.....
Gdip_DrawLines(pGraphics, hPen, Points)
{
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), "Float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "Float")
}
Return, DllCall("gdiplus\GdipDrawLines", "UInt", pGraphics, "UInt", hPen, "UInt", &PointF, "Int", Points0)
}
;#####################################################################################
; Fill shape
;#####################################################################################
Gdip_FillRectangle(pGraphics, hBrush, x, y, w, h)
{
Return, DllCall("gdiplus\GdipFillRectangle", "UInt", pGraphics, "Int", hBrush
, "Float", x, "Float", y, "Float", w, "Float", h)
}
; Points passed as x1,y1|x2,y2|x3,y3.....
Gdip_FillPolygon(pGraphics, hBrush, Points, FillMode=0)
{
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), "Float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "Float")
}
Return, DllCall("gdiplus\GdipFillPolygon", "UInt", pGraphics, "UInt", hBrush, "UInt", &PointF, "Int", Points0, "Int", FillMode)
}
Gdip_FillPie(pGraphics, hBrush, x, y, w, h, StartAngle, SweepAngle)
{
Return, DllCall("gdiplus\GdipFillPie", "UInt", pGraphics, "UInt", hBrush
, "Float", x, "Float", y, "Float", w, "Float", h, "Float", StartAngle, "Float", SweepAngle)
}
Gdip_FillEllipse(pGraphics, hBrush, x, y, w, h)
{
Return, DllCall("gdiplus\GdipFillEllipse", "UInt", pGraphics, "UInt", hBrush
, "Float", x, "Float", y, "Float", w, "Float", h, "Float")
}
;#####################################################################################
; Graphics/Bitmap functions
;#####################################################################################
Gdip_DrawImage(pGraphics, pBitmap, dx, dy, dw, dh, sx="", sy="", sw="", sh="", Trans="1.0")
{
If (sx != "") && (sy != "") && (sw != "") && (sh != "")
{
If (Trans != 1)
{
VarSetCapacity(ColorMatrix, 100, 0)
Loop, 5
NumPut((A_Index = 4) ? Trans : 1.0, ColorMatrix, (A_Index-1)*24, "Float")
DllCall("gdiplus\GdipCreateImageAttributes", "UInt*", ImageAttr)
DllCall("gdiplus\GdipSetImageAttributesColorMatrix", "UInt", ImageAttr, "Int", 1, "Int", 1, "UInt", &ColorMatrix, "Int", 0, "Int", 0)
}
E := DllCall("gdiplus\GdipDrawImageRectRectI", "UInt", pGraphics, "UInt", pBitmap, "Int", dx
, "Int", dy, "Int", dw, "Int", dh, "Int", sx, "Int", sy, "Int", sw
, "Int", sh, "Int", 2, "UInt", ImageAttr, "UInt", 0, "UInt", 0)
If (Trans != 1)
DllCall("gdiplus\GdipDisposeImageAttributes", "UInt", ImageAttr)
VarSetCapacity(ColorMatrix, 0)
Return, E
}
Else
{
Return DllCall("gdiplus\GdipDrawImageRectI", "UInt", pGraphics, "UInt", pBitmap, "Int", dx
, "Int", dy, "Int", dw, "Int", dh)
}
}
Gdip_SetPixel(pBitmap, x, y, ARGB)
{
Return, DllCall("gdiplus\GdipBitmapSetPixel", "UInt", pBitmap, "Int", x, "Int", y, "Int", ARGB)
}
Gdip_GraphicsFromHDC(hdc)
{
DllCall("gdiplus\GdipCreateFromHDC", "UInt", hdc, "UInt*", pGraphics)
Return, pGraphics
}
Gdip_CreateBitmap(Width, Height, Format=0x26200A)
{
DllCall("gdiplus\GdipCreateBitmapFromScan0", "Int", Width, "Int", Height, "Int", 0, "Int", Format, "UInt", 0, "UInt*", pBitmap)
Return pBitmap
}
Gdip_SaveBitmapToFile(pBitmap, sOutput)
{
StringSplit, OutputArray, sOutput, .
Extension := "." . OutputArray%OutputArray0%
If Extension not in .png,.bmp,.jpg,.tiff,.gif
Return, -1
DllCall("gdiplus\GdipGetImageEncodersSize", "UInt*", nCount, "UInt*", nSize)
VarSetCapacity(ci, nSize)
DllCall("gdiplus\GdipGetImageEncoders", "UInt", nCount, "UInt", nSize, "UInt", &ci)
If !(nCount && nSize)
Return, -5
Loop, %nCount%
{
nSize := DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76*(A_Index-1)+44), "Int", -1, "UInt", 0, "Int", 0, "UInt", 0, "UInt", 0)
VarSetCapacity(sString, nSize)
DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76*(A_Index-1)+44), "Int", -1, "Str", sString, "Int", nSize, "UInt", 0, "UInt", 0)
If !InStr(sString, Extension)
Continue
pCodec := &ci+76*(A_Index-1)
Break
}
If !pCodec
Return, -6
nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sOutput, "Int", -1, "UInt", 0, "Int", 0)
VarSetCapacity(wOutput, nSize*2)
DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sOutput, "Int", -1, "UInt", &wOutput, "Int", nSize)
VarSetCapacity(wOutput, -1)
If !VarSetCapacity(wOutput)
Return, -7
E := DllCall("gdiplus\GdipSaveImageToFile", "UInt", pBitmap, "UInt", &wOutput, "UInt", pCodec, "UInt", 0)
Return, E ? -8 : 0
}
Gdip_GetImageWidth(pBitmap)
{
DllCall("gdiplus\GdipGetImageWidth", "UInt", pBitmap, "UInt*", Width)
Return, Width
}
Gdip_GetImageHeight(pBitmap)
{
DllCall("gdiplus\GdipGetImageHeight", "UInt", pBitmap, "UInt*", Height)
Return, Height
}
Gdip_CreateBitmapFromFile(sFile)
{
VarSetCapacity(wFile, 1023)
DllCall("kernel32\MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sFile, "Int", -1, "UInt", &wFile, "Int", 512)
DllCall("gdiplus\GdipCreateBitmapFromFile", "UInt", &wFile, "UInt*", pBitmap)
Return, pBitmap
}
Gdip_GraphicsFromImage(pBitmap)
{
DllCall("gdiplus\GdipGetImageGraphicsContext", "UInt", pBitmap, "UInt*", pGraphics)
Return, pGraphics
}
;#####################################################################################
; Create resources
;#####################################################################################
Gdip_CreatePen(ARGB, w)
{
DllCall("gdiplus\GdipCreatePen1", "Int", ARGB, "Float", w, "Int", 2, "UInt*", hPen)
Return, hPen
}
Gdip_BrushCreateSolid(ARGB=0xff000000)
{
DllCall("gdiplus\GdipCreateSolidFill", "Int", ARGB, "UInt*", hBrush)
Return, hBrush
}
;#####################################################################################
; Delete resources
;#####################################################################################
Gdip_DeletePen(hPen)
{
Return, DllCall("gdiplus\GdipDeletePen", "UInt", hPen)
}
Gdip_DisposeImage(pBitmap)
{
Return, DllCall("gdiplus\GdipDisposeImage", "UInt", pBitmap)
}
Gdip_DeleteGraphics(pGraphics)
{
Return, DllCall("gdiplus\GdipDeleteGraphics", "UInt", pGraphics)
}
Gdip_DeleteBrush(hBrush)
{
Return, DllCall("gdiplus\GdipDeleteBrush", "UInt", hBrush)
}
Gdip_DeleteFont(hFont)
{
Return, DllCall("gdiplus\GdipDeleteFont", "UInt", hFont)
}
Gdip_DeleteStringFormat(hFormat)
{
Return, DllCall("gdiplus\GdipDeleteStringFormat", "UInt", hFormat)
}
Gdip_DeleteFontFamily(hFamily)
{
Return, DllCall("gdiplus\GdipDeleteFontFamily", "UInt", hFamily)
}
Gdip_DeleteMatrix(Matrix)
{
Return, DllCall("gdiplus\GdipDeleteMatrix", "UInt", Matrix)
}
;#####################################################################################
; Text functions
;#####################################################################################
Gdip_DrawString(pGraphics, sString, hFont, hFormat, hBrush, ByRef RectF)
{
nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0)
VarSetCapacity(wString, nSize*2)
DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize)
Return, DllCall("gdiplus\GdipDrawString", "UInt", pGraphics, "UInt", &wString, "Int", -1, "UInt", hFont, "UInt", &RectF, "UInt", hFormat, "UInt", hBrush)
}
Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF)
{
nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0)
VarSetCapacity(wString, nSize*2)
DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize)
VarSetCapacity(RC, 16)
DllCall("gdiplus\GdipMeasureString", "UInt", pGraphics, "UInt", &wString, "Int", -1, "UInt", hFont, "UInt", &RectF, "UInt", hFormat, "UInt", &RC, "UInt*", Chars, "UInt*", Lines)
Return, &RC ? NumGet(RC, 0, "Float") "|" NumGet(RC, 4, "Float") "|" NumGet(RC, 8, "Float") "|" NumGet(RC, 12, "Float") : 0
}
; Near = 0
; Center = 1
; Far = 2
Gdip_SetStringFormatAlign(hFormat, Align)
{
Return, DllCall("gdiplus\GdipSetStringFormatAlign", "UInt", hFormat, "Int", Align)
}
Gdip_StringFormatCreate(Format=0, Lang=0)
{
DllCall("gdiplus\GdipCreateStringFormat", "Int", Format, "Int", Lang, "UInt*", hFormat)
Return, hFormat
}
; Regular = 0
; Bold = 1
; Italic = 2
; BoldItalic = 3
; Underline = 4
; Strikeout = 8
Gdip_FontCreate(hFamily, Size, Style=0)
{
DllCall("gdiplus\GdipCreateFont", "UInt", hFamily, "Float", Size, "Int", Style, "Int", 0, "UInt*", hFont)
Return, hFont
}
Gdip_FontFamilyCreate(Font)
{
nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &Font, "Int", -1, "UInt", 0, "Int", 0)
VarSetCapacity(wFont, nSize*2)
DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &Font, "Int", -1, "UInt", &wFont, "Int", nSize)
DllCall("gdiplus\GdipCreateFontFamilyFromName", "UInt", &wFont, "UInt", 0, "UInt*", hFamily)
Return, hFamily
}
;#####################################################################################
; Matrix functions
;#####################################################################################
Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
{
DllCall("gdiplus\GdipCreateMatrix2", "Float", m11, "Float", m12, "Float", m21, "Float", m22, "Float", x, "Float", y, "UInt*", Matrix)
Return, Matrix
}
Gdip_CreateMatrix()
{
DllCall("gdiplus\GdipCreateMatrix", "UInt*", Matrix)
Return, Matrix
}
;#####################################################################################
; Quality functions
;#####################################################################################
; SystemDefault = 0
; SingleBitPerPixelGridFit = 1
; SingleBitPerPixel = 2
; AntiAliasGridFit = 3
; AntiAlias = 4
Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
{
Return, DllCall("gdiplus\GdipSetTextRenderingHint", "UInt", pGraphics, "Int", RenderingHint)
}
; Invalid = 0
; Default = 1
; LowQuality = 2
; HighQuality = 3
; Bilinear = 4
; Bicubic = 5
; NearestNeighbor = 6
; HighQualityBilinear = 7
; HighQualityBicubic = 8
Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
{
Return, DllCall("gdiplus\GdipSetInterpolationMode", "UInt", pGraphics, "Int", InterpolationMode)
}
; Default = 0
; HighSpeed = 1
; HighQuality = 2
; None = 3
; AntiAlias = 4
Gdip_SmoothingMode(pGraphics, SmoothingMode)
{
Return, DllCall("gdiplus\GdipSetSmoothingMode", "UInt", pGraphics, "Int", SmoothingMode)
}
; Replace = 0
; Intersect = 1
; Union = 2
; Xor = 3
; Exclude = 4
; Complement = 5
Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0)
{
Return, DllCall("gdiplus\GdipSetClipRect", "UInt", pGraphics, "Float", x, "Float", y, "Float", w, "Float", h, "Int", CombineMode)
}
;GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, CombineMode combineMode)
Gdip_ResetClip(pGraphics)
{
Return, DllCall("gdiplus\GdipResetClip", "UInt", pGraphics)
}
;#####################################################################################
; Extra functions
;#####################################################################################
Gdip_Startup()
{
If !DllCall("GetModuleHandle", "Str", "gdiplus")
DllCall("LoadLibrary", "Str", "gdiplus")
VarSetCapacity(si, 16, 0), si := Chr(1)
DllCall("gdiplus\GdiplusStartup", "UInt*", pToken, "UInt", &si, "UInt", 0)
VarSetCapacity(si, 0)
Return, pToken
}
Gdip_Shutdown(pToken)
{
DllCall("gdiplus\GdiplusShutdown", "UInt", pToken)
If hModule := DllCall("GetModuleHandle", "Str", "gdiplus")
DllCall("FreeLibrary", "UInt", hModule)
Return, 0
}