<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Кто-то сможет декомпилировать этот файл ?]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15241&amp;type=atom" />
	<updated>2020-03-18T10:28:38Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15241</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Кто-то сможет декомпилировать этот файл ?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138513#p138513" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
UpdateLayeredWindow(hwnd, hdc, x=&quot;&quot;, y=&quot;&quot;, w=&quot;&quot;, h=&quot;&quot;, Alpha=255)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
if ((x != &quot;&quot;) &amp;&amp; (y != &quot;&quot;))
VarSetCapacity(pt, 8), NumPut(x, pt, 0, &quot;UInt&quot;), NumPut(y, pt, 4, &quot;UInt&quot;)
if (w = &quot;&quot;) ||(h = &quot;&quot;)
WinGetPos,,, w, h, ahk_id %hwnd%
return DllCall(&quot;UpdateLayeredWindow&quot;
, Ptr, hwnd
, Ptr, 0
, Ptr, ((x = &quot;&quot;) &amp;&amp; (y = &quot;&quot;)) ? 0 : &amp;pt
, &quot;int64*&quot;, w|h&lt;&lt;32
, Ptr, hdc
, &quot;int64*&quot;, 0
, &quot;uint&quot;, 0
, &quot;UInt*&quot;, Alpha&lt;&lt;16|1&lt;&lt;24
, &quot;uint&quot;, 2)
}
BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster=&quot;&quot;)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdi32\BitBlt&quot;
, Ptr, dDC
, &quot;int&quot;, dx
, &quot;int&quot;, dy
, &quot;int&quot;, dw
, &quot;int&quot;, dh
, Ptr, sDC
, &quot;int&quot;, sx
, &quot;int&quot;, sy
, &quot;uint&quot;, Raster ? Raster : 0x00CC0020)
}
StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster=&quot;&quot;)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdi32\StretchBlt&quot;
, Ptr, ddc
, &quot;int&quot;, dx
, &quot;int&quot;, dy
, &quot;int&quot;, dw
, &quot;int&quot;, dh
, Ptr, sdc
, &quot;int&quot;, sx
, &quot;int&quot;, sy
, &quot;int&quot;, sw
, &quot;int&quot;, sh
, &quot;uint&quot;, Raster ? Raster : 0x00CC0020)
}
SetStretchBltMode(hdc, iStretchMode=4)
{
return DllCall(&quot;gdi32\SetStretchBltMode&quot;
, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc
, &quot;int&quot;, iStretchMode)
}
SetImage(hwnd, hBitmap)
{
SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
E := ErrorLevel
DeleteObject(E)
return E
}
SetSysColorToControl(hwnd, SysColor=15)
{
WinGetPos,,, w, h, ahk_id %hwnd%
bc := DllCall(&quot;GetSysColor&quot;, &quot;Int&quot;, SysColor, &quot;UInt&quot;)
pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc &gt;&gt; 16 | bc &amp; 0xff00 | (bc &amp; 0xff) &lt;&lt; 16))
pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
SetImage(hwnd, hBitmap)
Gdip_DeleteBrush(pBrushClear)
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
return 0
}
Gdip_BitmapFromScreen(Screen=0, Raster=&quot;&quot;)
{
if (Screen = 0)
{
Sysget, x, 76
Sysget, y, 77
Sysget, w, 78
Sysget, h, 79
}
else if (SubStr(Screen, 1, 5) = &quot;hwnd:&quot;)
{
Screen := SubStr(Screen, 6)
if !WinExist( &quot;ahk_id &quot; Screen)
return -2
WinGetPos,,, w, h, ahk_id %Screen%
x := y := 0
hhdc := GetDCEx(Screen, 3)
}
else if (Screen&amp;1 != &quot;&quot;)
{
Sysget, M, Monitor, %Screen%
x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
}
else
{
StringSplit, S, Screen, |
x := S1, y := S2, w := S3, h := S4
}
if (x = &quot;&quot;) || (y = &quot;&quot;) || (w = &quot;&quot;) || (h = &quot;&quot;)
return -1
chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
ReleaseDC(hhdc)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
return pBitmap
}
Gdip_BitmapFromHWND(hwnd)
{
WinGetPos,,, Width, Height, ahk_id %hwnd%
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
PrintWindow(hwnd, hdc)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
return pBitmap
}
CreateRectF(ByRef RectF, x, y, w, h)
{
VarSetCapacity(RectF, 16)
NumPut(x, RectF, 0, &quot;float&quot;), NumPut(y, RectF, 4, &quot;float&quot;), NumPut(w, RectF, 8, &quot;float&quot;), NumPut(h, RectF, 12, &quot;float&quot;)
}
CreateRect(ByRef Rect, x, y, w, h)
{
VarSetCapacity(Rect, 16)
NumPut(x, Rect, 0, &quot;uint&quot;), NumPut(y, Rect, 4, &quot;uint&quot;), NumPut(w, Rect, 8, &quot;uint&quot;), NumPut(h, Rect, 12, &quot;uint&quot;)
}
CreateSizeF(ByRef SizeF, w, h)
{
VarSetCapacity(SizeF, 8)
NumPut(w, SizeF, 0, &quot;float&quot;), NumPut(h, SizeF, 4, &quot;float&quot;)
}
CreatePointF(ByRef PointF, x, y)
{
VarSetCapacity(PointF, 8)
NumPut(x, PointF, 0, &quot;float&quot;), NumPut(y, PointF, 4, &quot;float&quot;)
}
CreateDIBSection(w, h, hdc=&quot;&quot;, bpp=32, ByRef ppvBits=0)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
hdc2 := hdc ? hdc : GetDC()
VarSetCapacity(bi, 40, 0)
NumPut(w, bi, 4, &quot;uint&quot;)
, NumPut(h, bi, 8, &quot;uint&quot;)
, NumPut(40, bi, 0, &quot;uint&quot;)
, NumPut(1, bi, 12, &quot;ushort&quot;)
, NumPut(0, bi, 16, &quot;uInt&quot;)
, NumPut(bpp, bi, 14, &quot;ushort&quot;)
hbm := DllCall(&quot;CreateDIBSection&quot;
, Ptr, hdc2
, Ptr, &amp;bi
, &quot;uint&quot;, 0
, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, ppvBits
, Ptr, 0
, &quot;uint&quot;, 0, Ptr)
if !hdc
ReleaseDC(hdc2)
return hbm
}
PrintWindow(hwnd, hdc, Flags=0)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;PrintWindow&quot;, Ptr, hwnd, Ptr, hdc, &quot;uint&quot;, Flags)
}
DestroyIcon(hIcon)
{
return DllCall(&quot;DestroyIcon&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hIcon)
}
PaintDesktop(hdc)
{
return DllCall(&quot;PaintDesktop&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc)
}
CreateCompatibleBitmap(hdc, w, h)
{
return DllCall(&quot;gdi32\CreateCompatibleBitmap&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc, &quot;int&quot;, w, &quot;int&quot;, h)
}
CreateCompatibleDC(hdc=0)
{
return DllCall(&quot;CreateCompatibleDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc)
}
SelectObject(hdc, hgdiobj)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;SelectObject&quot;, Ptr, hdc, Ptr, hgdiobj)
}
DeleteObject(hObject)
{
return DllCall(&quot;DeleteObject&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hObject)
}
GetDC(hwnd=0)
{
return DllCall(&quot;GetDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hwnd)
}
GetDCEx(hwnd, flags=0, hrgnClip=0)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;GetDCEx&quot;, Ptr, hwnd, Ptr, hrgnClip, &quot;int&quot;, flags)
}
ReleaseDC(hdc, hwnd=0)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;ReleaseDC&quot;, Ptr, hwnd, Ptr, hdc)
}
DeleteDC(hdc)
{
return DllCall(&quot;DeleteDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc)
}
Gdip_LibraryVersion()
{
return 1.45
}
Gdip_LibrarySubVersion()
{
return 1.47
}
Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
{
Static FName = &quot;ObjRelease&quot;
if !BRAFromMemIn
return -1
Loop, Parse, BRAFromMemIn, `n
{
if (A_Index = 1)
{
StringSplit, Header, A_LoopField, |
if (Header0 != 4 || Header2 != &quot;BRA!&quot;)
return -2
}
else if (A_Index = 2)
{
StringSplit, Info, A_LoopField, |
if (Info0 != 3)
return -3
}
else
break
}
if !Alternate
StringReplace, File, File, \, \\, All
RegExMatch(BRAFromMemIn, &quot;mi`n)^&quot; (Alternate ? File &quot;\|.+?\|(\d+)\|(\d+)&quot; : &quot;\d+\|&quot; File &quot;\|(\d+)\|(\d+)&quot;) &quot;$&quot;, FileInfo)
if !FileInfo
return -4
hData := DllCall(&quot;GlobalAlloc&quot;, &quot;uint&quot;, 2, Ptr, FileInfo2, Ptr)
pData := DllCall(&quot;GlobalLock&quot;, Ptr, hData, Ptr)
DllCall(&quot;RtlMoveMemory&quot;, Ptr, pData, Ptr, &amp;BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
DllCall(&quot;GlobalUnlock&quot;, Ptr, hData)
DllCall(&quot;ole32\CreateStreamOnHGlobal&quot;, Ptr, hData, &quot;int&quot;, 1, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pStream)
DllCall(&quot;gdiplus\GdipCreateBitmapFromStream&quot;, Ptr, pStream, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pBitmap)
If (A_PtrSize)
%FName%(pStream)
Else
DllCall(NumGet(NumGet(1*pStream)+8), &quot;uint&quot;, pStream)
return pBitmap
}
Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipDrawRectangle&quot;, Ptr, pGraphics, Ptr, pPen, &quot;float&quot;, x, &quot;float&quot;, y, &quot;float&quot;, w, &quot;float&quot;, h)
}
Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r)
{
Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
Gdip_ResetClip(pGraphics)
Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
Gdip_DrawEllipse(pGraphics, pPen, x, y, 2*r, 2*r)
Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y, 2*r, 2*r)
Gdip_DrawEllipse(pGraphics, pPen, x, y+h-(2*r), 2*r, 2*r)
Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
Gdip_ResetClip(pGraphics)
return E
}
Gdip_DrawEllipse(pGraphics, pPen, x, y, w, h)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipDrawEllipse&quot;, Ptr, pGraphics, Ptr, pPen, &quot;float&quot;, x, &quot;float&quot;, y, &quot;float&quot;, w, &quot;float&quot;, h)
}
Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipDrawBezier&quot;
, Ptr, pgraphics
, Ptr, pPen
, &quot;float&quot;, x1
, &quot;float&quot;, y1
, &quot;float&quot;, x2
, &quot;float&quot;, y2
, &quot;float&quot;, x3
, &quot;float&quot;, y3
, &quot;float&quot;, x4
, &quot;float&quot;, y4)
}
Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipDrawArc&quot;
, Ptr, pGraphics
, Ptr, pPen
, &quot;float&quot;, x
, &quot;float&quot;, y
, &quot;float&quot;, w
, &quot;float&quot;, h
, &quot;float&quot;, StartAngle
, &quot;float&quot;, SweepAngle)
}
Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipDrawPie&quot;, Ptr, pGraphics, Ptr, pPen, &quot;float&quot;, x, &quot;float&quot;, y, &quot;float&quot;, w, &quot;float&quot;, h, &quot;float&quot;, StartAngle, &quot;float&quot;, SweepAngle)
}
Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipDrawLine&quot;
, Ptr, pGraphics
, Ptr, pPen
, &quot;float&quot;, x1
, &quot;float&quot;, y1
, &quot;float&quot;, x2
, &quot;float&quot;, y2)
}
Gdip_DrawLines(pGraphics, pPen, Points)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), &quot;float&quot;), NumPut(Coord2, PointF, (8*(A_Index-1))+4, &quot;float&quot;)
}
return DllCall(&quot;gdiplus\GdipDrawLines&quot;, Ptr, pGraphics, Ptr, pPen, Ptr, &amp;PointF, &quot;int&quot;, Points0)
}
Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipFillRectangle&quot;
, Ptr, pGraphics
, Ptr, pBrush
, &quot;float&quot;, x
, &quot;float&quot;, y
, &quot;float&quot;, w
, &quot;float&quot;, h)
}
Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r)
{
Region := Gdip_GetClipRegion(pGraphics)
Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r), 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_DeleteRegion(Region)
return E
}
Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode=0)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), &quot;float&quot;), NumPut(Coord2, PointF, (8*(A_Index-1))+4, &quot;float&quot;)
}
return DllCall(&quot;gdiplus\GdipFillPolygon&quot;, Ptr, pGraphics, Ptr, pBrush, Ptr, &amp;PointF, &quot;int&quot;, Points0, &quot;int&quot;, FillMode)
}
Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipFillPie&quot;
, Ptr, pGraphics
, Ptr, pBrush
, &quot;float&quot;, x
, &quot;float&quot;, y
, &quot;float&quot;, w
, &quot;float&quot;, h
, &quot;float&quot;, StartAngle
, &quot;float&quot;, SweepAngle)
}
Gdip_FillEllipse(pGraphics, pBrush, x, y, w, h)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipFillEllipse&quot;, Ptr, pGraphics, Ptr, pBrush, &quot;float&quot;, x, &quot;float&quot;, y, &quot;float&quot;, w, &quot;float&quot;, h)
}
Gdip_FillRegion(pGraphics, pBrush, Region)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipFillRegion&quot;, Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
}
Gdip_FillPath(pGraphics, pBrush, Path)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipFillPath&quot;, Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
}
Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx=&quot;&quot;, sy=&quot;&quot;, sw=&quot;&quot;, sh=&quot;&quot;, Matrix=1)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), &quot;float&quot;), NumPut(Coord2, PointF, (8*(A_Index-1))+4, &quot;float&quot;)
}
if (Matrix&amp;1 = &quot;&quot;)
ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
else if (Matrix != 1)
ImageAttr := Gdip_SetImageAttributesColorMatrix(&quot;1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|&quot; Matrix &quot;|0|0|0|0|0|1&quot;)
if (sx = &quot;&quot; &amp;&amp; sy = &quot;&quot; &amp;&amp; sw = &quot;&quot; &amp;&amp; sh = &quot;&quot;)
{
sx := 0, sy := 0
sw := Gdip_GetImageWidth(pBitmap)
sh := Gdip_GetImageHeight(pBitmap)
}
E := DllCall(&quot;gdiplus\GdipDrawImagePointsRect&quot;
, Ptr, pGraphics
, Ptr, pBitmap
, Ptr, &amp;PointF
, &quot;int&quot;, Points0
, &quot;float&quot;, sx
, &quot;float&quot;, sy
, &quot;float&quot;, sw
, &quot;float&quot;, sh
, &quot;int&quot;, 2
, Ptr, ImageAttr
, Ptr, 0
, Ptr, 0)
if ImageAttr
Gdip_DisposeImageAttributes(ImageAttr)
return E
}
Gdip_DrawImage(pGraphics, pBitmap, dx=&quot;&quot;, dy=&quot;&quot;, dw=&quot;&quot;, dh=&quot;&quot;, sx=&quot;&quot;, sy=&quot;&quot;, sw=&quot;&quot;, sh=&quot;&quot;, Matrix=1)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
if (Matrix&amp;1 = &quot;&quot;)
ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
else if (Matrix != 1)
ImageAttr := Gdip_SetImageAttributesColorMatrix(&quot;1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|&quot; Matrix &quot;|0|0|0|0|0|1&quot;)
if (sx = &quot;&quot; &amp;&amp; sy = &quot;&quot; &amp;&amp; sw = &quot;&quot; &amp;&amp; sh = &quot;&quot;)
{
if (dx = &quot;&quot; &amp;&amp; dy = &quot;&quot; &amp;&amp; dw = &quot;&quot; &amp;&amp; dh = &quot;&quot;)
{
sx := dx := 0, sy := dy := 0
sw := dw := Gdip_GetImageWidth(pBitmap)
sh := dh := Gdip_GetImageHeight(pBitmap)
}
else
{
sx := sy := 0
sw := Gdip_GetImageWidth(pBitmap)
sh := Gdip_GetImageHeight(pBitmap)
}
}
E := DllCall(&quot;gdiplus\GdipDrawImageRectRect&quot;
, Ptr, pGraphics
, Ptr, pBitmap
, &quot;float&quot;, dx
, &quot;float&quot;, dy
, &quot;float&quot;, dw
, &quot;float&quot;, dh
, &quot;float&quot;, sx
, &quot;float&quot;, sy
, &quot;float&quot;, sw
, &quot;float&quot;, sh
, &quot;int&quot;, 2
, Ptr, ImageAttr
, Ptr, 0
, Ptr, 0)
if ImageAttr
Gdip_DisposeImageAttributes(ImageAttr)
return E
}
Gdip_SetImageAttributesColorMatrix(Matrix)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
VarSetCapacity(ColourMatrix, 100, 0)
Matrix := RegExReplace(RegExReplace(Matrix, &quot;^[^\d-\.]+([\d\.])&quot;, &quot;$1&quot;, &quot;&quot;, 1), &quot;[^\d-\.]+&quot;, &quot;|&quot;)
StringSplit, Matrix, Matrix, |
Loop, 25
{
Matrix := (Matrix%A_Index% != &quot;&quot;) ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1
NumPut(Matrix, ColourMatrix, (A_Index-1)*4, &quot;float&quot;)
}
DllCall(&quot;gdiplus\GdipCreateImageAttributes&quot;, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, ImageAttr)
DllCall(&quot;gdiplus\GdipSetImageAttributesColorMatrix&quot;, Ptr, ImageAttr, &quot;int&quot;, 1, &quot;int&quot;, 1, Ptr, &amp;ColourMatrix, Ptr, 0, &quot;int&quot;, 0)
return ImageAttr
}
Gdip_GraphicsFromImage(pBitmap)
{
DllCall(&quot;gdiplus\GdipGetImageGraphicsContext&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pGraphics)
return pGraphics
}
Gdip_GraphicsFromHDC(hdc)
{
DllCall(&quot;gdiplus\GdipCreateFromHDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hdc, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pGraphics)
return pGraphics
}
Gdip_GetDC(pGraphics)
{
DllCall(&quot;gdiplus\GdipGetDC&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, hdc)
return hdc
}
Gdip_ReleaseDC(pGraphics, hdc)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipReleaseDC&quot;, Ptr, pGraphics, Ptr, hdc)
}
Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
{
return DllCall(&quot;gdiplus\GdipGraphicsClear&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;int&quot;, ARGB)
}
Gdip_BlurBitmap(pBitmap, Blur)
{
if (Blur &gt; 100) || (Blur &lt; 1)
return -1
sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
dWidth := sWidth//Blur, dHeight := sHeight//Blur
pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
G1 := Gdip_GraphicsFromImage(pBitmap1)
Gdip_SetInterpolationMode(G1, 7)
Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
Gdip_DeleteGraphics(G1)
pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
G2 := Gdip_GraphicsFromImage(pBitmap2)
Gdip_SetInterpolationMode(G2, 7)
Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
Gdip_DeleteGraphics(G2)
Gdip_DisposeImage(pBitmap1)
return pBitmap2
}
Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
SplitPath, sOutput,,, Extension
if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
return -1
Extension := &quot;.&quot; Extension
DllCall(&quot;gdiplus\GdipGetImageEncodersSize&quot;, &quot;uint*&quot;, nCount, &quot;uint*&quot;, nSize)
VarSetCapacity(ci, nSize)
DllCall(&quot;gdiplus\GdipGetImageEncoders&quot;, &quot;uint&quot;, nCount, &quot;uint&quot;, nSize, Ptr, &amp;ci)
if !(nCount &amp;&amp; nSize)
return -2
If (A_IsUnicode){
StrGet_Name := &quot;StrGet&quot;
Loop, %nCount%
{
sString := %StrGet_Name%(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), &quot;UTF-16&quot;)
if !InStr(sString, &quot;*&quot; Extension)
continue
pCodec := &amp;ci+idx
break
}
} else {
Loop, %nCount%
{
Location := NumGet(ci, 76*(A_Index-1)+44)
nSize := DllCall(&quot;WideCharToMultiByte&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;uint&quot;, Location, &quot;int&quot;, -1, &quot;uint&quot;, 0, &quot;int&quot;,  0, &quot;uint&quot;, 0, &quot;uint&quot;, 0)
VarSetCapacity(sString, nSize)
DllCall(&quot;WideCharToMultiByte&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;uint&quot;, Location, &quot;int&quot;, -1, &quot;str&quot;, sString, &quot;int&quot;, nSize, &quot;uint&quot;, 0, &quot;uint&quot;, 0)
if !InStr(sString, &quot;*&quot; Extension)
continue
pCodec := &amp;ci+76*(A_Index-1)
break
}
}
if !pCodec
return -3
if (Quality != 75)
{
Quality := (Quality &lt; 0) ? 0 : (Quality &gt; 100) ? 100 : Quality
if Extension in .JPG,.JPEG,.JPE,.JFIF
{
DllCall(&quot;gdiplus\GdipGetEncoderParameterListSize&quot;, Ptr, pBitmap, Ptr, pCodec, &quot;uint*&quot;, nSize)
VarSetCapacity(EncoderParameters, nSize, 0)
DllCall(&quot;gdiplus\GdipGetEncoderParameterList&quot;, Ptr, pBitmap, Ptr, pCodec, &quot;uint&quot;, nSize, Ptr, &amp;EncoderParameters)
Loop, % NumGet(EncoderParameters, &quot;UInt&quot;)
{
elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
if (NumGet(EncoderParameters, elem+16, &quot;UInt&quot;) = 1) &amp;&amp; (NumGet(EncoderParameters, elem+20, &quot;UInt&quot;) = 6)
{
p := elem+&amp;EncoderParameters-pad-4
NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, &quot;UInt&quot;)), &quot;UInt&quot;)
break
}
}
}
}
if (!A_IsUnicode)
{
nSize := DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sOutput, &quot;int&quot;, -1, Ptr, 0, &quot;int&quot;, 0)
VarSetCapacity(wOutput, nSize*2)
DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sOutput, &quot;int&quot;, -1, Ptr, &amp;wOutput, &quot;int&quot;, nSize)
VarSetCapacity(wOutput, -1)
if !VarSetCapacity(wOutput)
return -4
E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, Ptr, pBitmap, Ptr, &amp;wOutput, Ptr, pCodec, &quot;uint&quot;, p ? p : 0)
}
else
E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, Ptr, pBitmap, Ptr, &amp;sOutput, Ptr, pCodec, &quot;uint&quot;, p ? p : 0)
return E ? -5 : 0
}
Gdip_GetPixel(pBitmap, x, y)
{
DllCall(&quot;gdiplus\GdipBitmapGetPixel&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, &quot;int&quot;, x, &quot;int&quot;, y, &quot;uint*&quot;, ARGB)
return ARGB
}
Gdip_SetPixel(pBitmap, x, y, ARGB)
{
return DllCall(&quot;gdiplus\GdipBitmapSetPixel&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, &quot;int&quot;, x, &quot;int&quot;, y, &quot;int&quot;, ARGB)
}
Gdip_GetImageWidth(pBitmap)
{
DllCall(&quot;gdiplus\GdipGetImageWidth&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, &quot;uint*&quot;, Width)
return Width
}
Gdip_GetImageHeight(pBitmap)
{
DllCall(&quot;gdiplus\GdipGetImageHeight&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, &quot;uint*&quot;, Height)
return Height
}
Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
DllCall(&quot;gdiplus\GdipGetImageWidth&quot;, Ptr, pBitmap, &quot;uint*&quot;, Width)
DllCall(&quot;gdiplus\GdipGetImageHeight&quot;, Ptr, pBitmap, &quot;uint*&quot;, Height)
}
Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
{
Gdip_GetImageDimensions(pBitmap, Width, Height)
}
Gdip_GetImagePixelFormat(pBitmap)
{
DllCall(&quot;gdiplus\GdipGetImagePixelFormat&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, Format)
return Format
}
Gdip_GetDpiX(pGraphics)
{
DllCall(&quot;gdiplus\GdipGetDpiX&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;uint&quot;, pGraphics, &quot;float*&quot;, dpix)
return Round(dpix)
}
Gdip_GetDpiY(pGraphics)
{
DllCall(&quot;gdiplus\GdipGetDpiY&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;uint&quot;, pGraphics, &quot;float*&quot;, dpiy)
return Round(dpiy)
}
Gdip_GetImageHorizontalResolution(pBitmap)
{
DllCall(&quot;gdiplus\GdipGetImageHorizontalResolution&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;uint&quot;, pBitmap, &quot;float*&quot;, dpix)
return Round(dpix)
}
Gdip_GetImageVerticalResolution(pBitmap)
{
DllCall(&quot;gdiplus\GdipGetImageVerticalResolution&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;uint&quot;, pBitmap, &quot;float*&quot;, dpiy)
return Round(dpiy)
}
Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
{
return DllCall(&quot;gdiplus\GdipBitmapSetResolution&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;uint&quot;, pBitmap, &quot;float&quot;, dpix, &quot;float&quot;, dpiy)
}
Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize=&quot;&quot;)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
, PtrA := A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;
SplitPath, sFile,,, ext
if ext in exe,dll
{
Sizes := IconSize ? IconSize : 256 &quot;|&quot; 128 &quot;|&quot; 64 &quot;|&quot; 48 &quot;|&quot; 32 &quot;|&quot; 16
BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
VarSetCapacity(buf, BufSize, 0)
Loop, Parse, Sizes, |
{
DllCall(&quot;PrivateExtractIcons&quot;, &quot;str&quot;, sFile, &quot;int&quot;, IconNumber-1, &quot;int&quot;, A_LoopField, &quot;int&quot;, A_LoopField, PtrA, hIcon, PtrA, 0, &quot;uint&quot;, 1, &quot;uint&quot;, 0)
if !hIcon
continue
if !DllCall(&quot;GetIconInfo&quot;, Ptr, hIcon, Ptr, &amp;buf)
{
DestroyIcon(hIcon)
continue
}
hbmMask  := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
if !(hbmColor &amp;&amp; DllCall(&quot;GetObject&quot;, Ptr, hbmColor, &quot;int&quot;, BufSize, Ptr, &amp;buf))
{
DestroyIcon(hIcon)
continue
}
break
}
if !hIcon
return -1
Width := NumGet(buf, 4, &quot;int&quot;), Height := NumGet(buf, 8, &quot;int&quot;)
hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
if !DllCall(&quot;DrawIconEx&quot;, Ptr, hdc, &quot;int&quot;, 0, &quot;int&quot;, 0, Ptr, hIcon, &quot;uint&quot;, Width, &quot;uint&quot;, Height, &quot;uint&quot;, 0, Ptr, 0, &quot;uint&quot;, 3)
{
DestroyIcon(hIcon)
return -2
}
VarSetCapacity(dib, 104)
DllCall(&quot;GetObject&quot;, Ptr, hbm, &quot;int&quot;, A_PtrSize = 8 ? 104 : 84, Ptr, &amp;dib)
Stride := NumGet(dib, 12, &quot;Int&quot;), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0))
DllCall(&quot;gdiplus\GdipCreateBitmapFromScan0&quot;, &quot;int&quot;, Width, &quot;int&quot;, Height, &quot;int&quot;, Stride, &quot;int&quot;, 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
pBitmap := Gdip_CreateBitmap(Width, Height)
G := Gdip_GraphicsFromImage(pBitmap)
, Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
DestroyIcon(hIcon)
}
else
{
if (!A_IsUnicode)
{
VarSetCapacity(wFile, 1024)
DllCall(&quot;kernel32\MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sFile, &quot;int&quot;, -1, Ptr, &amp;wFile, &quot;int&quot;, 512)
DllCall(&quot;gdiplus\GdipCreateBitmapFromFile&quot;, Ptr, &amp;wFile, PtrA, pBitmap)
}
else
DllCall(&quot;gdiplus\GdipCreateBitmapFromFile&quot;, Ptr, &amp;sFile, PtrA, pBitmap)
}
return pBitmap
}
Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
DllCall(&quot;gdiplus\GdipCreateBitmapFromHBITMAP&quot;, Ptr, hBitmap, Ptr, Palette, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, pBitmap)
return pBitmap
}
Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
{
DllCall(&quot;gdiplus\GdipCreateHBITMAPFromBitmap&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, hbm, &quot;int&quot;, Background)
return hbm
}
Gdip_CreateBitmapFromHICON(hIcon)
{
DllCall(&quot;gdiplus\GdipCreateBitmapFromHICON&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hIcon, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, pBitmap)
return pBitmap
}
Gdip_CreateHICONFromBitmap(pBitmap)
{
DllCall(&quot;gdiplus\GdipCreateHICONFromBitmap&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, hIcon)
return hIcon
}
Gdip_CreateBitmap(Width, Height, Format=0x26200A)
{
DllCall(&quot;gdiplus\GdipCreateBitmapFromScan0&quot;, &quot;int&quot;, Width, &quot;int&quot;, Height, &quot;int&quot;, 0, &quot;int&quot;, Format, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, 0, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, pBitmap)
Return pBitmap
}
Gdip_CreateBitmapFromClipboard()
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
if !DllCall(&quot;OpenClipboard&quot;, Ptr, 0)
return -1
if !DllCall(&quot;IsClipboardFormatAvailable&quot;, &quot;uint&quot;, 8)
return -2
if !hBitmap := DllCall(&quot;GetClipboardData&quot;, &quot;uint&quot;, 2, Ptr)
return -3
if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
return -4
if !DllCall(&quot;CloseClipboard&quot;)
return -5
DeleteObject(hBitmap)
return pBitmap
}
Gdip_SetBitmapToClipboard(pBitmap)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
DllCall(&quot;GetObject&quot;, Ptr, hBitmap, &quot;int&quot;, VarSetCapacity(oi, A_PtrSize = 8 ? 104 : 84, 0), Ptr, &amp;oi)
hdib := DllCall(&quot;GlobalAlloc&quot;, &quot;uint&quot;, 2, Ptr, 40+NumGet(oi, off1, &quot;UInt&quot;), Ptr)
pdib := DllCall(&quot;GlobalLock&quot;, Ptr, hdib, Ptr)
DllCall(&quot;RtlMoveMemory&quot;, Ptr, pdib, Ptr, &amp;oi+off2, Ptr, 40)
DllCall(&quot;RtlMoveMemory&quot;, Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4), Ptr), Ptr, NumGet(oi, off1, &quot;UInt&quot;))
DllCall(&quot;GlobalUnlock&quot;, Ptr, hdib)
DllCall(&quot;DeleteObject&quot;, Ptr, hBitmap)
DllCall(&quot;OpenClipboard&quot;, Ptr, 0)
DllCall(&quot;EmptyClipboard&quot;)
DllCall(&quot;SetClipboardData&quot;, &quot;uint&quot;, 8, Ptr, hdib)
DllCall(&quot;CloseClipboard&quot;)
}
Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
{
DllCall(&quot;gdiplus\GdipCloneBitmapArea&quot;
, &quot;float&quot;, x
, &quot;float&quot;, y
, &quot;float&quot;, w
, &quot;float&quot;, h
, &quot;int&quot;, Format
, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap
, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pBitmapDest)
return pBitmapDest
}
Gdip_CreatePen(ARGB, w)
{
DllCall(&quot;gdiplus\GdipCreatePen1&quot;, &quot;UInt&quot;, ARGB, &quot;float&quot;, w, &quot;int&quot;, 2, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pPen)
return pPen
}
Gdip_CreatePenFromBrush(pBrush, w)
{
DllCall(&quot;gdiplus\GdipCreatePen2&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBrush, &quot;float&quot;, w, &quot;int&quot;, 2, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pPen)
return pPen
}
Gdip_BrushCreateSolid(ARGB=0xff000000)
{
DllCall(&quot;gdiplus\GdipCreateSolidFill&quot;, &quot;UInt&quot;, ARGB, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pBrush)
return pBrush
}
Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
{
DllCall(&quot;gdiplus\GdipCreateHatchBrush&quot;, &quot;int&quot;, HatchStyle, &quot;UInt&quot;, ARGBfront, &quot;UInt&quot;, ARGBback, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pBrush)
return pBrush
}
Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w=&quot;&quot;, h=&quot;&quot;)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
, PtrA := A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;
if !(w &amp;&amp; h)
DllCall(&quot;gdiplus\GdipCreateTexture&quot;, Ptr, pBitmap, &quot;int&quot;, WrapMode, PtrA, pBrush)
else
DllCall(&quot;gdiplus\GdipCreateTexture2&quot;, Ptr, pBitmap, &quot;int&quot;, WrapMode, &quot;float&quot;, x, &quot;float&quot;, y, &quot;float&quot;, w, &quot;float&quot;, h, PtrA, pBrush)
return pBrush
}
Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
DllCall(&quot;gdiplus\GdipCreateLineBrush&quot;, Ptr, &amp;PointF1, Ptr, &amp;PointF2, &quot;Uint&quot;, ARGB1, &quot;Uint&quot;, ARGB2, &quot;int&quot;, WrapMode, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, LGpBrush)
return LGpBrush
}
Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1)
{
CreateRectF(RectF, x, y, w, h)
DllCall(&quot;gdiplus\GdipCreateLineBrushFromRect&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, &amp;RectF, &quot;int&quot;, ARGB1, &quot;int&quot;, ARGB2, &quot;int&quot;, LinearGradientMode, &quot;int&quot;, WrapMode, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, LGpBrush)
return LGpBrush
}
Gdip_CloneBrush(pBrush)
{
DllCall(&quot;gdiplus\GdipCloneBrush&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBrush, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, pBrushClone)
return pBrushClone
}
Gdip_DeletePen(pPen)
{
return DllCall(&quot;gdiplus\GdipDeletePen&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pPen)
}
Gdip_DeleteBrush(pBrush)
{
return DllCall(&quot;gdiplus\GdipDeleteBrush&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBrush)
}
Gdip_DisposeImage(pBitmap)
{
return DllCall(&quot;gdiplus\GdipDisposeImage&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap)
}
Gdip_DeleteGraphics(pGraphics)
{
return DllCall(&quot;gdiplus\GdipDeleteGraphics&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics)
}
Gdip_DisposeImageAttributes(ImageAttr)
{
return DllCall(&quot;gdiplus\GdipDisposeImageAttributes&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, ImageAttr)
}
Gdip_DeleteFont(hFont)
{
return DllCall(&quot;gdiplus\GdipDeleteFont&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hFont)
}
Gdip_DeleteStringFormat(hFormat)
{
return DllCall(&quot;gdiplus\GdipDeleteStringFormat&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hFormat)
}
Gdip_DeleteFontFamily(hFamily)
{
return DllCall(&quot;gdiplus\GdipDeleteFontFamily&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hFamily)
}
Gdip_DeleteMatrix(Matrix)
{
return DllCall(&quot;gdiplus\GdipDeleteMatrix&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, Matrix)
}
Gdip_TextToGraphics(pGraphics, Text, Options, Font=&quot;Arial&quot;, Width=&quot;&quot;, Height=&quot;&quot;, Measure=0)
{
IWidth := Width, IHeight:= Height
RegExMatch(Options, &quot;i)X([\-\d\.]+)(p*)&quot;, xpos)
RegExMatch(Options, &quot;i)Y([\-\d\.]+)(p*)&quot;, ypos)
RegExMatch(Options, &quot;i)W([\-\d\.]+)(p*)&quot;, Width)
RegExMatch(Options, &quot;i)H([\-\d\.]+)(p*)&quot;, Height)
RegExMatch(Options, &quot;i)C(?!(entre|enter))([a-f\d]+)&quot;, Colour)
RegExMatch(Options, &quot;i)Top|Up|Bottom|Down|vCentre|vCenter&quot;, vPos)
RegExMatch(Options, &quot;i)NoWrap&quot;, NoWrap)
RegExMatch(Options, &quot;i)R(\d)&quot;, Rendering)
RegExMatch(Options, &quot;i)S(\d+)(p*)&quot;, Size)
if !Gdip_DeleteBrush(Gdip_CloneBrush(Colour2))
PassBrush := 1, pBrush := Colour2
if !(IWidth &amp;&amp; IHeight) &amp;&amp; (xpos2 || ypos2 || Width2 || Height2 || Size2)
return -1
Style := 0, Styles := &quot;Regular|Bold|Italic|BoldItalic|Underline|Strikeout&quot;
Loop, Parse, Styles, |
{
if RegExMatch(Options, &quot;\b&quot; A_loopField)
Style |= (A_LoopField != &quot;StrikeOut&quot;) ? (A_Index-1) : 8
}
Align := 0, Alignments := &quot;Near|Left|Centre|Center|Far|Right&quot;
Loop, Parse, Alignments, |
{
if RegExMatch(Options, &quot;\b&quot; A_loopField)
Align |= A_Index//2.1
}
xpos := (xpos1 != &quot;&quot;) ? xpos2 ? IWidth*(xpos1/100) : xpos1 : 0
ypos := (ypos1 != &quot;&quot;) ? ypos2 ? IHeight*(ypos1/100) : ypos1 : 0
Width := Width1 ? Width2 ? IWidth*(Width1/100) : Width1 : IWidth
Height := Height1 ? Height2 ? IHeight*(Height1/100) : Height1 : IHeight
if !PassBrush
Colour := &quot;0x&quot; (Colour2 ? Colour2 : &quot;ff000000&quot;)
Rendering := ((Rendering1 &gt;= 0) &amp;&amp; (Rendering1 &lt;= 5)) ? Rendering1 : 4
Size := (Size1 &gt; 0) ? Size2 ? IHeight*(Size1/100) : Size1 : 12
hFamily := Gdip_FontFamilyCreate(Font)
hFont := Gdip_FontCreate(hFamily, Size, Style)
FormatStyle := NoWrap ? 0x4000 | 0x1000 : 0x4000
hFormat := Gdip_StringFormatCreate(FormatStyle)
pBrush := PassBrush ? pBrush : Gdip_BrushCreateSolid(Colour)
if !(hFamily &amp;&amp; hFont &amp;&amp; hFormat &amp;&amp; pBrush &amp;&amp; pGraphics)
return !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !pBrush ? -6 : 0
CreateRectF(RC, xpos, ypos, Width, Height)
Gdip_SetStringFormatAlign(hFormat, Align)
Gdip_SetTextRenderingHint(pGraphics, Rendering)
ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
if vPos
{
StringSplit, ReturnRC, ReturnRC, |
if (vPos = &quot;vCentre&quot;) || (vPos = &quot;vCenter&quot;)
ypos += (Height-ReturnRC4)//2
else if (vPos = &quot;Top&quot;) || (vPos = &quot;Up&quot;)
ypos := 0
else if (vPos = &quot;Bottom&quot;) || (vPos = &quot;Down&quot;)
ypos := Height-ReturnRC4
CreateRectF(RC, xpos, ypos, Width, ReturnRC4)
ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
}
if !Measure
E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC)
if !PassBrush
Gdip_DeleteBrush(pBrush)
Gdip_DeleteStringFormat(hFormat)
Gdip_DeleteFont(hFont)
Gdip_DeleteFontFamily(hFamily)
return E ? E : ReturnRC
}
Gdip_DrawString(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
if (!A_IsUnicode)
{
nSize := DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sString, &quot;int&quot;, -1, Ptr, 0, &quot;int&quot;, 0)
VarSetCapacity(wString, nSize*2)
DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sString, &quot;int&quot;, -1, Ptr, &amp;wString, &quot;int&quot;, nSize)
}
return DllCall(&quot;gdiplus\GdipDrawString&quot;
, Ptr, pGraphics
, Ptr, A_IsUnicode ? &amp;sString : &amp;wString
, &quot;int&quot;, -1
, Ptr, hFont
, Ptr, &amp;RectF
, Ptr, hFormat
, Ptr, pBrush)
}
Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
VarSetCapacity(RC, 16)
if !A_IsUnicode
{
nSize := DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sString, &quot;int&quot;, -1, &quot;uint&quot;, 0, &quot;int&quot;, 0)
VarSetCapacity(wString, nSize*2)
DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;sString, &quot;int&quot;, -1, Ptr, &amp;wString, &quot;int&quot;, nSize)
}
DllCall(&quot;gdiplus\GdipMeasureString&quot;
, Ptr, pGraphics
, Ptr, A_IsUnicode ? &amp;sString : &amp;wString
, &quot;int&quot;, -1
, Ptr, hFont
, Ptr, &amp;RectF
, Ptr, hFormat
, Ptr, &amp;RC
, &quot;uint*&quot;, Chars
, &quot;uint*&quot;, Lines)
return &amp;RC ? NumGet(RC, 0, &quot;float&quot;) &quot;|&quot; NumGet(RC, 4, &quot;float&quot;) &quot;|&quot; NumGet(RC, 8, &quot;float&quot;) &quot;|&quot; NumGet(RC, 12, &quot;float&quot;) &quot;|&quot; Chars &quot;|&quot; Lines : 0
}
Gdip_SetStringFormatAlign(hFormat, Align)
{
return DllCall(&quot;gdiplus\GdipSetStringFormatAlign&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hFormat, &quot;int&quot;, Align)
}
Gdip_StringFormatCreate(Format=0, Lang=0)
{
DllCall(&quot;gdiplus\GdipCreateStringFormat&quot;, &quot;int&quot;, Format, &quot;int&quot;, Lang, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, hFormat)
return hFormat
}
Gdip_FontCreate(hFamily, Size, Style=0)
{
DllCall(&quot;gdiplus\GdipCreateFont&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, hFamily, &quot;float&quot;, Size, &quot;int&quot;, Style, &quot;int&quot;, 0, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, hFont)
return hFont
}
Gdip_FontFamilyCreate(Font)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
if (!A_IsUnicode)
{
nSize := DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;Font, &quot;int&quot;, -1, &quot;uint&quot;, 0, &quot;int&quot;, 0)
VarSetCapacity(wFont, nSize*2)
DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0, Ptr, &amp;Font, &quot;int&quot;, -1, Ptr, &amp;wFont, &quot;int&quot;, nSize)
}
DllCall(&quot;gdiplus\GdipCreateFontFamilyFromName&quot;
, Ptr, A_IsUnicode ? &amp;Font : &amp;wFont
, &quot;uint&quot;, 0
, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, hFamily)
return hFamily
}
Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
{
DllCall(&quot;gdiplus\GdipCreateMatrix2&quot;, &quot;float&quot;, m11, &quot;float&quot;, m12, &quot;float&quot;, m21, &quot;float&quot;, m22, &quot;float&quot;, x, &quot;float&quot;, y, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, Matrix)
return Matrix
}
Gdip_CreateMatrix()
{
DllCall(&quot;gdiplus\GdipCreateMatrix&quot;, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, Matrix)
return Matrix
}
Gdip_CreatePath(BrushMode=0)
{
DllCall(&quot;gdiplus\GdipCreatePath&quot;, &quot;int&quot;, BrushMode, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, Path)
return Path
}
Gdip_AddPathEllipse(Path, x, y, w, h)
{
return DllCall(&quot;gdiplus\GdipAddPathEllipse&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, Path, &quot;float&quot;, x, &quot;float&quot;, y, &quot;float&quot;, w, &quot;float&quot;, h)
}
Gdip_AddPathPolygon(Path, Points)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), &quot;float&quot;), NumPut(Coord2, PointF, (8*(A_Index-1))+4, &quot;float&quot;)
}
return DllCall(&quot;gdiplus\GdipAddPathPolygon&quot;, Ptr, Path, Ptr, &amp;PointF, &quot;int&quot;, Points0)
}
Gdip_DeletePath(Path)
{
return DllCall(&quot;gdiplus\GdipDeletePath&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, Path)
}
Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
{
return DllCall(&quot;gdiplus\GdipSetTextRenderingHint&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;int&quot;, RenderingHint)
}
Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
{
return DllCall(&quot;gdiplus\GdipSetInterpolationMode&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;int&quot;, InterpolationMode)
}
Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
{
return DllCall(&quot;gdiplus\GdipSetSmoothingMode&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;int&quot;, SmoothingMode)
}
Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
{
return DllCall(&quot;gdiplus\GdipSetCompositingMode&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;int&quot;, CompositingMode)
}
Gdip_Startup()
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
if !DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;gdiplus&quot;, Ptr)
DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;gdiplus&quot;)
VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
DllCall(&quot;gdiplus\GdiplusStartup&quot;, A_PtrSize ? &quot;UPtr*&quot; : &quot;uint*&quot;, pToken, Ptr, &amp;si, Ptr, 0)
return pToken
}
Gdip_Shutdown(pToken)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
DllCall(&quot;gdiplus\GdiplusShutdown&quot;, Ptr, pToken)
if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;gdiplus&quot;, Ptr)
DllCall(&quot;FreeLibrary&quot;, Ptr, hModule)
return 0
}
Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
{
return DllCall(&quot;gdiplus\GdipRotateWorldTransform&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;float&quot;, Angle, &quot;int&quot;, MatrixOrder)
}
Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
{
return DllCall(&quot;gdiplus\GdipScaleWorldTransform&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;float&quot;, x, &quot;float&quot;, y, &quot;int&quot;, MatrixOrder)
}
Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
{
return DllCall(&quot;gdiplus\GdipTranslateWorldTransform&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;float&quot;, x, &quot;float&quot;, y, &quot;int&quot;, MatrixOrder)
}
Gdip_ResetWorldTransform(pGraphics)
{
return DllCall(&quot;gdiplus\GdipResetWorldTransform&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics)
}
Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
{
pi := 3.14159, TAngle := Angle*(pi/180)
Bound := (Angle &gt;= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
if ((Bound &gt;= 0) &amp;&amp; (Bound &lt;= 90))
xTranslation := Height*Sin(TAngle), yTranslation := 0
else if ((Bound &gt; 90) &amp;&amp; (Bound &lt;= 180))
xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
else if ((Bound &gt; 180) &amp;&amp; (Bound &lt;= 270))
xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
else if ((Bound &gt; 270) &amp;&amp; (Bound &lt;= 360))
xTranslation := 0, yTranslation := -Width*Sin(TAngle)
}
Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
{
pi := 3.14159, TAngle := Angle*(pi/180)
if !(Width &amp;&amp; Height)
return -1
RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
}
Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
{
return DllCall(&quot;gdiplus\GdipImageRotateFlip&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pBitmap, &quot;int&quot;, RotateFlipType)
}
Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0)
{
return DllCall(&quot;gdiplus\GdipSetClipRect&quot;,  A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;float&quot;, x, &quot;float&quot;, y, &quot;float&quot;, w, &quot;float&quot;, h, &quot;int&quot;, CombineMode)
}
Gdip_SetClipPath(pGraphics, Path, CombineMode=0)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipSetClipPath&quot;, Ptr, pGraphics, Ptr, Path, &quot;int&quot;, CombineMode)
}
Gdip_ResetClip(pGraphics)
{
return DllCall(&quot;gdiplus\GdipResetClip&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics)
}
Gdip_GetClipRegion(pGraphics)
{
Region := Gdip_CreateRegion()
DllCall(&quot;gdiplus\GdipGetClip&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, pGraphics, &quot;UInt*&quot;, Region)
return Region
}
Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;gdiplus\GdipSetClipRegion&quot;, Ptr, pGraphics, Ptr, Region, &quot;int&quot;, CombineMode)
}
Gdip_CreateRegion()
{
DllCall(&quot;gdiplus\GdipCreateRegion&quot;, &quot;UInt*&quot;, Region)
return Region
}
Gdip_DeleteRegion(Region)
{
return DllCall(&quot;gdiplus\GdipDeleteRegion&quot;, A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;, Region)
}
Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
CreateRect(Rect, x, y, w, h)
VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
E := DllCall(&quot;Gdiplus\GdipBitmapLockBits&quot;, Ptr, pBitmap, Ptr, &amp;Rect, &quot;uint&quot;, LockMode, &quot;int&quot;, PixelFormat, Ptr, &amp;BitmapData)
Stride := NumGet(BitmapData, 8, &quot;Int&quot;)
Scan0 := NumGet(BitmapData, 16, Ptr)
return E
}
Gdip_UnlockBits(pBitmap, ByRef BitmapData)
{
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
return DllCall(&quot;Gdiplus\GdipBitmapUnlockBits&quot;, Ptr, pBitmap, Ptr, &amp;BitmapData)
}
Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
{
Numput(ARGB, Scan0+0, (x*4)+(y*Stride), &quot;UInt&quot;)
}
Gdip_GetLockBitPixel(Scan0, x, y, Stride)
{
return NumGet(Scan0+0, (x*4)+(y*Stride), &quot;UInt&quot;)
}
Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
{
static PixelateBitmap
Ptr := A_PtrSize ? &quot;UPtr&quot; : &quot;UInt&quot;
if (!PixelateBitmap)
{
if A_PtrSize != 8
MCode_PixelateBitmap =
		(LTrim Join
		558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
		397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
		8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
		4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
		C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
		8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
		148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
		B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
		F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
		038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
		1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
		FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
		D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
		45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
		89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
		0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
		75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
		8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
		B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
		451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
		75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
		8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
)
else
MCode_PixelateBitmap =
		(LTrim Join
		4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
		448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
		4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
		C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
		24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
		004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
		0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
		DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
		024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
		99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
		8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
		4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
		000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
		ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
		4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
		99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
		8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
		2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
		FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
		83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
		F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
		0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
		413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
)
VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
Loop % StrLen(MCode_PixelateBitmap)//2
NumPut(&quot;0x&quot; SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, &quot;UChar&quot;)
DllCall(&quot;VirtualProtect&quot;, Ptr, &amp;PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), &quot;uint&quot;, 0x40, A_PtrSize ? &quot;UPtr*&quot; : &quot;UInt*&quot;, 0)
}
Gdip_GetImageDimensions(pBitmap, Width, Height)
if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
return -1
if (BlockSize &gt; Width || BlockSize &gt; Height)
return -2
E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
if (E1 || E2)
return -3
E := DllCall(&amp;PixelateBitmap, Ptr, Scan01, Ptr, Scan02, &quot;int&quot;, Width, &quot;int&quot;, Height, &quot;int&quot;, Stride1, &quot;int&quot;, BlockSize)
Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
return 0
}
Gdip_ToARGB(A, R, G, B)
{
return (A &lt;&lt; 24) | (R &lt;&lt; 16) | (G &lt;&lt; 8) | B
}
Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
{
A := (0xff000000 &amp; ARGB) &gt;&gt; 24
R := (0x00ff0000 &amp; ARGB) &gt;&gt; 16
G := (0x0000ff00 &amp; ARGB) &gt;&gt; 8
B := 0x000000ff &amp; ARGB
}
Gdip_AFromARGB(ARGB)
{
return (0xff000000 &amp; ARGB) &gt;&gt; 24
}
Gdip_RFromARGB(ARGB)
{
return (0x00ff0000 &amp; ARGB) &gt;&gt; 16
}
Gdip_GFromARGB(ARGB)
{
return (0x0000ff00 &amp; ARGB) &gt;&gt; 8
}
Gdip_BFromARGB(ARGB)
{
return 0x000000ff &amp; ARGB
}
StrGetB(Address, Length=-1, Encoding=0)
{
if Length is not integer
Encoding := Length,  Length := -1
if (Address+0 &lt; 1024)
return
if Encoding = UTF-16
Encoding = 1200
else if Encoding = UTF-8
Encoding = 65001
else if SubStr(Encoding,1,2)=&quot;CP&quot;
Encoding := SubStr(Encoding,3)
if !Encoding
{
if (Length == -1)
Length := DllCall(&quot;lstrlen&quot;, &quot;uint&quot;, Address)
VarSetCapacity(String, Length)
DllCall(&quot;lstrcpyn&quot;, &quot;str&quot;, String, &quot;uint&quot;, Address, &quot;int&quot;, Length + 1)
}
else if Encoding = 1200
{
char_count := DllCall(&quot;WideCharToMultiByte&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0x400, &quot;uint&quot;, Address, &quot;int&quot;, Length, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;uint&quot;, 0, &quot;uint&quot;, 0)
VarSetCapacity(String, char_count)
DllCall(&quot;WideCharToMultiByte&quot;, &quot;uint&quot;, 0, &quot;uint&quot;, 0x400, &quot;uint&quot;, Address, &quot;int&quot;, Length, &quot;str&quot;, String, &quot;int&quot;, char_count, &quot;uint&quot;, 0, &quot;uint&quot;, 0)
}
else if Encoding is integer
{
char_count := DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, Encoding, &quot;uint&quot;, 0, &quot;uint&quot;, Address, &quot;int&quot;, Length, &quot;uint&quot;, 0, &quot;int&quot;, 0)
VarSetCapacity(String, char_count * 2)
char_count := DllCall(&quot;MultiByteToWideChar&quot;, &quot;uint&quot;, Encoding, &quot;uint&quot;, 0, &quot;uint&quot;, Address, &quot;int&quot;, Length, &quot;uint&quot;, &amp;String, &quot;int&quot;, char_count * 2)
String := StrGetB(&amp;String, char_count, 1200)
}
return String
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[DarkBrain]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40689</uri>
			</author>
			<updated>2020-03-18T10:28:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138513#p138513</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Кто-то сможет декомпилировать этот файл ?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138511#p138511" />
			<content type="html"><![CDATA[<p>Кто-то сможет декомпилировать этот файл ?<br />Результаты можете прикрепить ниже (прикрепить не удалось). Даю так: <a href="https://dropmefiles.com/dVHqc">https://dropmefiles.com/dVHqc</a>.</p>]]></content>
			<author>
				<name><![CDATA[${neg}]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40674</uri>
			</author>
			<updated>2020-03-18T03:53:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138511#p138511</id>
		</entry>
</feed>
