_GDIPlus_BitmapCreateBlurBitmap()

Recommended Posts

This function allows you to blur the specified GDI+ bitmap with different force of blur (see screenshots, 1 - source image, 2 - blurring image with L=5, 3 - blurring image with L=10). The source bitmap may be of any color depth, the output bitmap is always 32 bits-per-pixel with alpha channel. The function creates a few parallel threads (up to 8), that significantly reduces the time consumption. It's worth noting that the blurring is performed for all channels, including the alpha channel.

The following shows the basic algorithm for a simple blur of bitmap written in AutoIt. Unfortunately, it is not possible to solve using AutoIt because the processing of even a small picture may require too much time. For example, blurring image 100x100 can last a few seconds. To solve this problem, I compiled the time-consuming part of code (main loop) to machine code. This solved the problem of the time consumption but I wanted to get better results, especially for large images (more than 1000x1000) and large blur radius (10+). Then I divided the source image into several parts and started the blurring of each part in a separate thread. Now it's become quite good. See below for a complete example written for Autoit 3.3.12.0.

```; Scans the source bitmap pixel by pixel
For \$Yi = 0 To \$H - 1
For \$Xi = To \$W - 1
\$A = 0
\$R = 0
\$G = 0
\$B = 0
\$Count = 0
; Calculates the average value for each color channel of source bitmap (including alpha chennel)
For \$Yj = \$Yi - \$L To \$Yi + \$L
For \$Xj = \$Xi - \$L To \$Xi + \$L
If (\$Xj >= 0) And (\$Xj < \$W) And (\$Yj >= 0) And (\$Yj < \$H) Then
\$ARGB = DllStructCreate('BYTE B;BYTE G;BYTE R;BYTE A', \$pBitsSrc + (\$Xj + \$Yj * \$W) * 4)
\$A += \$ARGB.A
\$R += \$ARGB.R
\$G += \$ARGB.G
\$B += \$ARGB.B
\$Count += 1
EndIf
Next
Next
; Writes the calculated color to the corresponding pixel of destination bitmap
\$ARGB = DllStructCreate('BYTE B;BYTE G;BYTE R;BYTE A', \$pBitsDst + (\$Xj + \$Yj * \$W) * 4)
\$ARGB.A = \$A / \$Count
\$ARGB.R = \$R / \$Count
\$ARGB.G = \$G / \$Count
\$ARGB.B = \$B / \$Count
Next
Next```

```#Include <GDIPlus.au3>

If StringRegExpReplace(@AutoItVersion, '(?<!\d)(\d)(?!\d)', '0\1') < '03.03.12.00' Then
MsgBox(16, 'Error', 'Require AutoIt 3.3.12.0 or later.')
EndIf

\$sFile = @ScriptDir & '\Birds.png'

_GDIPlus_Startup()
\$hBitmap = _GDIPlus_BitmapCreateFromFile(\$sFile)
\$hBlur = _GDIPlus_BitmapCreateBlurBitmap(\$hBitmap, 5, 1)
_GDIPlus_ImageSaveToFile(\$hBlur, StringRegExpReplace(\$sFile, '(\.[^\.]+)', '_Blur\1'))
_GDIPlus_BitmapDispose(\$hBlur)
_GDIPlus_BitmapDispose(\$hBitmap)
_GDIPlus_Shutdown()

Func _GDIPlus_BitmapCreateBlurBitmap(\$hBitmap, \$iRadius, \$fAccurate = False)

Local \$tData[2], \$hThread, \$iThread, \$tParams, \$bProc, \$tProc, \$pProc, \$aSize, \$aHeight, \$iLength, \$hResult, \$aResult

\$aSize = DllCall(\$__g_hGDIPDll, 'uint', 'GdipGetImageDimension', 'handle', \$hBitmap, 'float*', 0, 'float*', 0)
If (@Error) Or (\$aSize[0]) Then
Return 0
EndIf
For \$i = 2 To 3
EndIf
Next
Return 0
EndIf
\$hResult  = _GDIPlus_BitmapCreateFromScan0(\$aSize[2], \$aSize[3], \$GDIP_PXF32ARGB)
\$tData[0] = _GDIPlus_BitmapLockBits(\$hBitmap, 0, 0, \$aSize[2], \$aSize[3], \$GDIP_ILMREAD,  \$GDIP_PXF32ARGB)
\$tData[1] = _GDIPlus_BitmapLockBits(\$hResult, 0, 0, \$aSize[2], \$aSize[3], \$GDIP_ILMWRITE, \$GDIP_PXF32ARGB)
If @AutoItX64 Then
\$bProc = Binary('0x48894C24085541574156415548C7C00A0000004883EC0848C704240000000048FFC875EF4883EC28488BAC24A000000048837D000074054831C0EB0748C7C0010000004821C00F855E010000488BAC24A000000048837D080074054831C0EB0748C7C0010000004821C00F8527010000488BAC24A0000000837D180074054831C0EB0748C7C0010000004821C00F85F1000000488BAC24A0000000837D1C0074054831C0EB0748C7C0010000004821C00F85BB000000488BAC24A0000000837D200074054831C0EB0748C7C0010000004821C00F8585000000488BAC24A0000000837D240074054831C0EB0748C7C0010000004821C07553488BAC24A0000000837D280074054831C0EB0748C7C0010000004821C07521488BAC24A0000000837D2C0074054831C0EB0748C7C0010000004821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C0740B4831C04863C0E946030000488BAC24A00000004863451450584889442428488BAC24A00000004C637D14488BAC24A00000004863451C4901C749FFCF4C3B7C24280F8CFB020000488BAC24A00000004863451050584889442430488BAC24A00000004C637D10488BAC24A0000000486345184901C749FFCF4C3B7C24300F8CB402000048C74424380000000048C74424400000000048C74424480000000048C74424500000000048C7442458000000004C8B7C2428488BAC24A0000000486345284929C74C897C24604C8B7C24604C8B742428488BAC24A0000000486345284901C64D39F70F8F840100004C8B7C2430488BAC24A0000000486345284929C74C897C24684C8B7C24684C8B742430488BAC24A0000000486345284901C64D39F70F8F2B0100004C8B7C24684D21FF7C614C8B7C2468488BAC24A0000000486345204939C77D3A4C8B7C24604D21FF7C1F4C8B7C2460488BAC24A0000000486345244939C77D0948C7C001000000EB034831C04821C0740948C7C001000000EB034831C04821C0740948C7C001000000EB034831C04821C00F8496000000488BAC24A00000004C8B7D004C8B7424684C8B6C2460488BAC24A0000000486345204C0FAFE84D01EE49C1E6024D01F74C897C24704C8B7C2438488B6C2470480FB645034901C74C897C24384C8B7C2440488B6C2470480FB645024901C74C897C24404C8B7C2448488B6C2470480FB645014901C74C897C24484C8B7C2450488B6C2470480FB645004901C74C897C245048FF4424584C8B7C2468488BAC24A00000004863452C4901C74C897C2468E9B3FEFFFF4C8B7C2460488BAC24A00000004863452C4901C74C897C2460E95AFEFFFF488BAC24A00000004C8B7D084C8B7424304C8B6C2428488BAC24A0000000486345204C0FAFE84D01EE49C1E6024D01F74C897C24704C8B7C2438FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845034C8B7C2440FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845024C8B7C2448FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845014C8B7C2450FF7424584C89F859489948F7F94989C74C89F850488B6C24785888450048FF4424300F8123FDFFFF48FF4424280F81DCFCFFFF48C7C0010000004863C0EB034831C04883C478415D415E415F5DC3')
Else
\$bProc = Binary('0x55535756BA0A00000083EC04C70424000000004A75F38B6C243C837D0000740431C0EB05B80100000021C00F85090100008B6C243C837D0400740431C0EB05B80100000021C00F85DF0000008B6C243C837D1000740431C0EB05B80100000021C00F85B50000008B6C243C837D1400740431C0EB05B80100000021C00F858B0000008B6C243C837D1800740431C0EB05B80100000021C075658B6C243C837D1C00740431C0EB05B80100000021C0753F8B6C243C837D2000740431C0EB05B80100000021C075198B6C243C837D2400740431C0EB05B80100000021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C0740731C0E9400200008B6C243C8B450C8904248B6C243C8B5D0C8B6C243C035D144B3B1C240F8C150200008B6C243C8B4508894424048B6C243C8B5D088B6C243C035D104B3B5C24040F8CE8010000C744240800000000C744240C00000000C744241000000000C744241400000000C7442418000000008B1C248B6C243C2B5D20895C241C8B5C241C8B3C248B6C243C037D2039FB0F8F0D0100008B5C24048B6C243C2B5D20895C24208B5C24208B7C24048B6C243C037D2039FB0F8FD30000008B5C242021DB7C438B5C24208B6C243C3B5D187D298B5C241C21DB7C148B5C241C8B6C243C3B5D1C7D07B801000000EB0231C021C07407B801000000EB0231C021C07407B801000000EB0231C021C0746E8B6C243C8B5D008B7C24208B74241C8B6C243C0FAF751801F7C1E70201FB895C24248B5C24088B6C24240FB6450301C3895C24088B5C240C8B6C24240FB6450201C3895C240C8B5C24108B6C24240FB6450101C3895C24108B5C24148B6C24240FB6450001C3895C2414FF4424188B5C24208B6C243C035D24895C2420E916FFFFFF8B5C241C8B6C243C035D24895C241CE9DDFEFFFF8B6C243C8B5D048B7C24048B34248B6C243C0FAF751801F7C1E70201FB895C24248B5C2408FF74241889D85999F7F989C3538B6C2428588845038B5C240CFF74241889D85999F7F989C3538B6C2428588845028B5C2410FF74241889D85999F7F989C3538B6C2428588845018B5C2414FF74241889D85999F7F989C3538B6C242858884500FF4424040F81FFFDFFFFFF04240F81D3FDFFFFB801000000EB0231C083C4285E5F5B5DC20400')
EndIf
\$iLength = BinaryLen(\$bProc)
\$pProc = DllCall('kernel32.dll', 'ptr', 'VirtualAlloc', 'ptr', 0, 'ulong_ptr', \$iLength, 'dword', 0x1000, 'dword', 0x0040)
\$tProc = DllStructCreate('byte[' & \$iLength & ']', \$pProc[0])
DllStructSetData(\$tProc, 1, \$bProc)
EndIf
\$aHeight[0] = \$aSize[3]
Else
For \$i = 1 To \$iThread - 2
\$aHeight[\$i] = \$aHeight[0]
Next
EndIf
\$iLength = 0
For \$i = 0 To \$iThread - 1
\$tParams[\$i] = DllStructCreate('ptr;ptr;uint;uint;uint;uint;uint;uint;uint;uint')
DllStructSetData(\$tParams[\$i], 1, \$tData[0].Scan0)
DllStructSetData(\$tParams[\$i], 2, \$tData[1].Scan0)
DllStructSetData(\$tParams[\$i], 3, 0)
DllStructSetData(\$tParams[\$i], 4, \$iLength)
DllStructSetData(\$tParams[\$i], 5, \$aSize[2])
DllStructSetData(\$tParams[\$i], 6, \$aHeight[\$i])
DllStructSetData(\$tParams[\$i], 7, \$aSize[2])
DllStructSetData(\$tParams[\$i], 8, \$aSize[3])
If \$fAccurate Then
DllStructSetData(\$tParams[\$i],10, 1)
Else
DllStructSetData(\$tParams[\$i],10, 2)
EndIf
\$iLength+= \$aHeight[\$i]
\$aResult = DllCall('kernel32.dll', 'handle', 'CreateThread', 'ptr', 0, 'dword_ptr', 0, 'ptr', \$pProc[0], 'struct*', \$tParams[\$i], 'dword', 0, 'ptr', 0)
If (Not @Error) And (\$aResult[0]) Then
Else
EndIf
Next
While 1
\$iLength = 0
For \$i = 0 To \$iThread - 1
If (@Error) Or (Not \$aResult[0]) Or (\$aResult[2] <> 259) Then
Else
\$iLength += 1
EndIf
EndIf
Next
If Not \$iLength Then
ExitLoop
EndIf
WEnd
\$aResult = DllCall('kernel32.dll', 'int', 'VirtualFree', 'ptr', \$pProc[0], 'ulong_ptr', 0, 'dword', 0x4000)
If (@Error) Or (Not \$aResult[0]) Then
; Nothing
EndIf
_GDIPlus_BitmapUnlockBits(\$hResult, \$tData[1])
_GDIPlus_BitmapUnlockBits(\$hBitmap, \$tData[0])
Return \$hResult
EndFunc   ;==>_GDIPlus_BitmapCreateBlurBitmap```

Function + Example

GDIPlus_BitmapCreateBlurBitmap.zip

Edited by Yashied

Share on other sites

I compared the speed of following 3 blur functions:

```#include <Screencapture.au3>

If StringRegExpReplace(@AutoItVersion, '(?<!\d)(\d)(?!\d)', '0\1') < '03.03.12.00' Then
MsgBox(16, 'Error', 'Require AutoIt 3.3.12.0 or later.')
EndIf

\$sFile = @ScriptDir & '\Birds.png'

_GDIPlus_Startup()
\$hGDI = _ScreenCapture_Capture("", 1, 1, 1024, 768)
\$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP(\$hGDI)
\$t = TimerInit()
\$hBlur = _GDIPlus_BitmapCreateBlurBitmap(\$hBitmap, 5, 1)
ConsoleWrite(TimerDiff(\$t) & @CRLF)
\$t = TimerInit()
\$hBlur2 = _GDIPlus_BitmapCreateBlurBitmapv10(\$hBitmap)
ConsoleWrite(TimerDiff(\$t) & @CRLF)
\$t = TimerInit()
_GDIPlus_BitmapCreateBlurBitmapv11(\$hBitmap, 10)
ConsoleWrite(TimerDiff(\$t) & @CRLF)

_GDIPlus_ImageSaveToFile(\$hBlur, StringRegExpReplace(\$sFile, '(\.[^\.]+)', '_Blur\1'))
_GDIPlus_ImageSaveToFile(\$hBlur2, StringRegExpReplace(\$sFile, '(\.[^\.]+)', '_Blur2\1'))
_GDIPlus_ImageSaveToFile(\$hBitmap, StringRegExpReplace(\$sFile, '(\.[^\.]+)', '_Blur3\1'))
_GDIPlus_BitmapDispose(\$hBlur)
_GDIPlus_BitmapDispose(\$hBlur2)
_GDIPlus_BitmapDispose(\$hBitmap)
_WinAPI_DeleteObject(\$hGDI)
_GDIPlus_Shutdown()

Func _GDIPlus_BitmapCreateBlurBitmapv11(\$hBitmap, \$iRadius) ;requires GDIPlus v1.1 available on Vista and higher operating systems
_GDIPlus_BitmapApplyEffect(\$hBitmap, \$hEffect)
_GDIPlus_EffectDispose(\$hEffect)
Return 1
EndFunc

Func _GDIPlus_BitmapCreateBlurBitmapv10(\$hBitmap, \$fScale = 0.2, \$iQual = 6); by eukalyptus
Local Const \$iW = _GDIPlus_ImageGetWidth(\$hBitmap), \$iH = _GDIPlus_ImageGetHeight(\$hBitmap)
Local Const \$hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
Local Const \$hBmpSmall = _GDIPlus_BitmapCreateFromGraphics(\$iW, \$iH, \$hGraphics)
Local Const \$hGfxSmall = _GDIPlus_ImageGetGraphicsContext(\$hBmpSmall)
_GDIPlus_GraphicsSetPixelOffsetMode(\$hGfxSmall, \$GDIP_PIXELOFFSETMODE_HIGHQUALITY)
Local Const \$hBmpBig = _GDIPlus_BitmapCreateFromGraphics(\$iW, \$iH, \$hGraphics)
Local Const \$hGfxBig = _GDIPlus_ImageGetGraphicsContext(\$hBmpBig)
_GDIPlus_GraphicsSetPixelOffsetMode(\$hGfxBig, \$GDIP_PIXELOFFSETMODE_HIGHQUALITY)
_GDIPlus_GraphicsScaleTransform(\$hGfxSmall, \$fScale, \$fScale)
_GDIPlus_GraphicsSetInterpolationMode(\$hGfxSmall, \$iQual)
_GDIPlus_GraphicsScaleTransform(\$hGfxBig, 1 / \$fScale, 1 / \$fScale)
_GDIPlus_GraphicsSetInterpolationMode(\$hGfxBig, \$iQual)
_GDIPlus_GraphicsDrawImageRect(\$hGfxSmall, \$hBitmap, 0, 0, \$iW, \$iH)
_GDIPlus_GraphicsDrawImageRect(\$hGfxBig, \$hBmpSmall, 0, 0, \$iW, \$iH)
_GDIPlus_GraphicsDispose(\$hGraphics)
_GDIPlus_BitmapDispose(\$hBmpSmall)
_GDIPlus_GraphicsDispose(\$hGfxSmall)
_GDIPlus_GraphicsDispose(\$hGfxBig)
Return \$hBmpBig
EndFunc   ;==>_Blur

Func _GDIPlus_BitmapCreateBlurBitmap(\$hBitmap, \$iRadius, \$fAccurate = False)

Local \$tData[2], \$hThread, \$iThread, \$tParams, \$bProc, \$tProc, \$pProc, \$aSize, \$aHeight, \$iLength, \$hResult, \$aResult

\$aSize = DllCall(\$__g_hGDIPDll, 'uint', 'GdipGetImageDimension', 'handle', \$hBitmap, 'float*', 0, 'float*', 0)
If (@Error) Or (\$aSize[0]) Then
Return 0
EndIf
For \$i = 2 To 3
EndIf
Next
Return 0
EndIf
\$hResult  = _GDIPlus_BitmapCreateFromScan0(\$aSize[2], \$aSize[3], \$GDIP_PXF32ARGB)
\$tData[0] = _GDIPlus_BitmapLockBits(\$hBitmap, 0, 0, \$aSize[2], \$aSize[3], \$GDIP_ILMREAD,  \$GDIP_PXF32ARGB)
\$tData[1] = _GDIPlus_BitmapLockBits(\$hResult, 0, 0, \$aSize[2], \$aSize[3], \$GDIP_ILMWRITE, \$GDIP_PXF32ARGB)
If @AutoItX64 Then
\$bProc = Binary('0x48894C24085541574156415548C7C00A0000004883EC0848C704240000000048FFC875EF4883EC28488BAC24A000000048837D000074054831C0EB0748C7C0010000004821C00F855E010000488BAC24A000000048837D080074054831C0EB0748C7C0010000004821C00F8527010000488BAC24A0000000837D180074054831C0EB0748C7C0010000004821C00F85F1000000488BAC24A0000000837D1C0074054831C0EB0748C7C0010000004821C00F85BB000000488BAC24A0000000837D200074054831C0EB0748C7C0010000004821C00F8585000000488BAC24A0000000837D240074054831C0EB0748C7C0010000004821C07553488BAC24A0000000837D280074054831C0EB0748C7C0010000004821C07521488BAC24A0000000837D2C0074054831C0EB0748C7C0010000004821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C0740B4831C04863C0E946030000488BAC24A00000004863451450584889442428488BAC24A00000004C637D14488BAC24A00000004863451C4901C749FFCF4C3B7C24280F8CFB020000488BAC24A00000004863451050584889442430488BAC24A00000004C637D10488BAC24A0000000486345184901C749FFCF4C3B7C24300F8CB402000048C74424380000000048C74424400000000048C74424480000000048C74424500000000048C7442458000000004C8B7C2428488BAC24A0000000486345284929C74C897C24604C8B7C24604C8B742428488BAC24A0000000486345284901C64D39F70F8F840100004C8B7C2430488BAC24A0000000486345284929C74C897C24684C8B7C24684C8B742430488BAC24A0000000486345284901C64D39F70F8F2B0100004C8B7C24684D21FF7C614C8B7C2468488BAC24A0000000486345204939C77D3A4C8B7C24604D21FF7C1F4C8B7C2460488BAC24A0000000486345244939C77D0948C7C001000000EB034831C04821C0740948C7C001000000EB034831C04821C0740948C7C001000000EB034831C04821C00F8496000000488BAC24A00000004C8B7D004C8B7424684C8B6C2460488BAC24A0000000486345204C0FAFE84D01EE49C1E6024D01F74C897C24704C8B7C2438488B6C2470480FB645034901C74C897C24384C8B7C2440488B6C2470480FB645024901C74C897C24404C8B7C2448488B6C2470480FB645014901C74C897C24484C8B7C2450488B6C2470480FB645004901C74C897C245048FF4424584C8B7C2468488BAC24A00000004863452C4901C74C897C2468E9B3FEFFFF4C8B7C2460488BAC24A00000004863452C4901C74C897C2460E95AFEFFFF488BAC24A00000004C8B7D084C8B7424304C8B6C2428488BAC24A0000000486345204C0FAFE84D01EE49C1E6024D01F74C897C24704C8B7C2438FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845034C8B7C2440FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845024C8B7C2448FF7424584C89F859489948F7F94989C74C89F850488B6C2478588845014C8B7C2450FF7424584C89F859489948F7F94989C74C89F850488B6C24785888450048FF4424300F8123FDFFFF48FF4424280F81DCFCFFFF48C7C0010000004863C0EB034831C04883C478415D415E415F5DC3')
Else
\$bProc = Binary('0x55535756BA0A00000083EC04C70424000000004A75F38B6C243C837D0000740431C0EB05B80100000021C00F85090100008B6C243C837D0400740431C0EB05B80100000021C00F85DF0000008B6C243C837D1000740431C0EB05B80100000021C00F85B50000008B6C243C837D1400740431C0EB05B80100000021C00F858B0000008B6C243C837D1800740431C0EB05B80100000021C075658B6C243C837D1C00740431C0EB05B80100000021C0753F8B6C243C837D2000740431C0EB05B80100000021C075198B6C243C837D2400740431C0EB05B80100000021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C0740731C0E9400200008B6C243C8B450C8904248B6C243C8B5D0C8B6C243C035D144B3B1C240F8C150200008B6C243C8B4508894424048B6C243C8B5D088B6C243C035D104B3B5C24040F8CE8010000C744240800000000C744240C00000000C744241000000000C744241400000000C7442418000000008B1C248B6C243C2B5D20895C241C8B5C241C8B3C248B6C243C037D2039FB0F8F0D0100008B5C24048B6C243C2B5D20895C24208B5C24208B7C24048B6C243C037D2039FB0F8FD30000008B5C242021DB7C438B5C24208B6C243C3B5D187D298B5C241C21DB7C148B5C241C8B6C243C3B5D1C7D07B801000000EB0231C021C07407B801000000EB0231C021C07407B801000000EB0231C021C0746E8B6C243C8B5D008B7C24208B74241C8B6C243C0FAF751801F7C1E70201FB895C24248B5C24088B6C24240FB6450301C3895C24088B5C240C8B6C24240FB6450201C3895C240C8B5C24108B6C24240FB6450101C3895C24108B5C24148B6C24240FB6450001C3895C2414FF4424188B5C24208B6C243C035D24895C2420E916FFFFFF8B5C241C8B6C243C035D24895C241CE9DDFEFFFF8B6C243C8B5D048B7C24048B34248B6C243C0FAF751801F7C1E70201FB895C24248B5C2408FF74241889D85999F7F989C3538B6C2428588845038B5C240CFF74241889D85999F7F989C3538B6C2428588845028B5C2410FF74241889D85999F7F989C3538B6C2428588845018B5C2414FF74241889D85999F7F989C3538B6C242858884500FF4424040F81FFFDFFFFFF04240F81D3FDFFFFB801000000EB0231C083C4285E5F5B5DC20400')
EndIf
\$iLength = BinaryLen(\$bProc)
\$pProc = DllCall('kernel32.dll', 'ptr', 'VirtualAlloc', 'ptr', 0, 'ulong_ptr', \$iLength, 'dword', 0x1000, 'dword', 0x0040)
\$tProc = DllStructCreate('byte[' & \$iLength & ']', \$pProc[0])
DllStructSetData(\$tProc, 1, \$bProc)
EndIf
\$aHeight[0] = \$aSize[3]
Else
For \$i = 1 To \$iThread - 2
\$aHeight[\$i] = \$aHeight[0]
Next
EndIf
\$iLength = 0
For \$i = 0 To \$iThread - 1
\$tParams[\$i] = DllStructCreate('ptr;ptr;uint;uint;uint;uint;uint;uint;uint;uint')
DllStructSetData(\$tParams[\$i], 1, \$tData[0].Scan0)
DllStructSetData(\$tParams[\$i], 2, \$tData[1].Scan0)
DllStructSetData(\$tParams[\$i], 3, 0)
DllStructSetData(\$tParams[\$i], 4, \$iLength)
DllStructSetData(\$tParams[\$i], 5, \$aSize[2])
DllStructSetData(\$tParams[\$i], 6, \$aHeight[\$i])
DllStructSetData(\$tParams[\$i], 7, \$aSize[2])
DllStructSetData(\$tParams[\$i], 8, \$aSize[3])
If \$fAccurate Then
DllStructSetData(\$tParams[\$i],10, 1)
Else
DllStructSetData(\$tParams[\$i],10, 2)
EndIf
\$iLength+= \$aHeight[\$i]
\$aResult = DllCall('kernel32.dll', 'handle', 'CreateThread', 'ptr', 0, 'dword_ptr', 0, 'ptr', \$pProc[0], 'struct*', \$tParams[\$i], 'dword', 0, 'ptr', 0)
If (Not @Error) And (\$aResult[0]) Then
Else
EndIf
Next
While 1
\$iLength = 0
For \$i = 0 To \$iThread - 1
If (@Error) Or (Not \$aResult[0]) Or (\$aResult[2] <> 259) Then
Else
\$iLength += 1
EndIf
EndIf
Next
If Not \$iLength Then
ExitLoop
EndIf
WEnd
\$aResult = DllCall('kernel32.dll', 'int', 'VirtualFree', 'ptr', \$pProc[0], 'ulong_ptr', 0, 'dword', 0x4000)
If (@Error) Or (Not \$aResult[0]) Then
; Nothing
EndIf
_GDIPlus_BitmapUnlockBits(\$hResult, \$tData[1])
_GDIPlus_BitmapUnlockBits(\$hBitmap, \$tData[0])
Return \$hResult
EndFunc   ;==>_GDIPlus_BitmapCreateBlurBitmap```

My results (in ms):

```450.636964902269
43.2380725602171
151.866555545064```

I tried the blur effects to be similar as possible.

Br,

UEZ

Edited by UEZ

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Create an account

Register a new account

• Similar Content

• By UEZ
AutoIt Windows Screenshooter
Key Features:
takes easily a screenshot from any visible window capture any region of the desktop incl. freehand capturing capture GUI controls and GUI menus separately capture a marked area every x seconds for a duration of y seconds create a GIF animation from saved frames (Vista or higher os required) capture to AVI file (without audio!) takes a screenshot from web sites (available only on Win7+ os and when Aero is enabled) put images to clipboard to paste to other applications easily color picker save image in different formats and also to PDF! add timestamp to saved images simple image editing options: greyscale, b&w, invert, rotate +-90° send image to printer and default email client preview of captured screens incl. zoom option multi monitor support display pixel color under mouse ruler basic image editor (paint, highlight, ellipse, rectangle, text and some graphic FX) watermark captured image no 3rd party tools or DLLs used - pure AutoIt! fully portable - no installation is needed multi language feature (Eng, Ger, Tur, Fra and Rus only) drag'n'drop an image to the app for editing To do:
capture content of scrollable window/control capture cascaded menus Due to DllCall("User32.dll", "int", "PrintWindow", "hwnd", \$hWnd, "handle", \$hMemDC, "int", 0) limitation some windows cannot be captured properly (GDI+, ProgDVB, etc.) but can take screenshots of hidden windows. One workaround is to use full screen capturing (F11/F12) or "Grab Screen" function! Or try double click with rmb on listview items (beta).
You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name!
Distributing copies of the program in compiled format (exe) must be free of any fee!
(Current donators: 1. Cuong N.)

It is designed for Win7+ operating systems with AERO enabled! E.g. on WinXP machines some functions are not working properly and might crash the application!
AV scanners may have a negative impact the execution of compiled exe and might report any malware. I guarantee that there is no malicious code in the source code / exe!!!
Main GUI:

Basic Image Editor:

Watermark:

Click link for an enhanced version of Watermark Image.
Credits:
main code by UEZ additional code (alphabetical order) by Authenticity, AutoItObject Team, Eemuli, Eukalyptus, funkey, _Kurt, martin, monoceres, ProgAndy, taietel, trancexx, Ward, wolf9228 and Yashied! mesale0077 for turkish translation wakillon for french translation AZJIO for russian translation Keys:
Main GUI:
User your mouse to scroll preview window or
Numpad 8: Scroll preview window up
Numpad 2: Scroll preview window down
Numpad 4: Scroll preview window left
Numpad 6: Scroll preview window right
Numpad +: zoom in preview window or mouse wheel down
Numpad -: zoom out preview window or mouse wheel up
F1: capture again on last position
F5: refresh Windows Name list
PRINTSCREEN: take screenshot from whole screen
ALT+PRINTSCR: take a screenshot from active window
F10: Undo made changes with Image Editing function
F11: take screenshot from whole screen incl mouse cursor
F12: take screenshot from whole screen
Ctrl+Alt+F9 start "Grab Screen" mode
Ctrl+Alt+F12: take a screenshot from active window using alternative screenshot functionality (beta)!
Ctrl+r: call ruler
Ctrl+s: save current displayed image
Ctrl+x: exit program
ctrl+w: call web grab input field (available only when Aero is enabled)
Ctrl+i: call image editor
Ctrl+m: call watermark editor
Ctrl+z: undo
Only available on Vista+ os: double click with rmb on list items to use alternative screenshot functionality (beta)!
When 'Grab Screen' is clicked you can hold down the ctrl key to switch to 'grab controls' mode. Control under mouse will be framed red.
ctrl + shift will take the screenshot of appropriate control. To capture GUI menus you can press rmb which simulates the lmb. When a menu is opened press shift additionally to capture it.
Press and hold only the shift key to capture any region on the desktop using freehand capturing - release it so capture marked regions!
Or just mark resize able area which you want to grab. Press CTRL key to grab marked area or right mouse button to capture the marked area every x seconds for a duration of y seconds.
When saving the image just enter the extension you wish to use (*.jpg;*.png;*.bmp;*.gif;*.tif;*.pdf). Big thanks to taietel for his PDF UDF!
Image Editor:
s: save
c: copy
n: send
h: highlighter
p: pen
r: rectangle
e: ellipse
a: arrow
o: color
t: text
g: text config
Ctrl+z: undo
Watermark editor:
Ctrl+z: undo

To start the app minimized just call it "Windows Screenshooter.exe /min"
Maybe it is useful for someone...
Any kind of comment is welcome.
Br,
UEZ
Change log:

• By UEZ

Requires Windows7+ OS!

Widget style GUI: