Ich hab das Script im englischen Forum gefunden und könnte es gut brauchen, aber nur wenn es ein klein wenig
anders funktioniert. Ich habe schon einige Stunden damit verbracht, aber ich verstehe höchstens 1/4 von dem Script.
Was ich bräuchte wäre eine Möglichkeit ein kleines Auswahlrechteck zu definieren(entweder per Auswahl mit der Maus oder einfach 4 Variablen für die Kordinaten) in dem später die Verspixelung
stattfindet, noch wird einfach das komplette Bild verpixelt.
Und ausserdem wäre eine Funktion zum Speichern notwendig bevorzugt per FileSaveDialog, weil es flexibel ist.
Hier das Original von UEZ
Spoiler anzeigen
#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
AutoItSetOption("GUIOnEventMode", 1)
_GDIPlus_Startup() ;initialize GDI+
Global $hBmp = _GDIPlus_BitmapCreateFromMemory(_Test_Image())
Local Const $iWidth = _GDIPlus_ImageGetWidth($hBmp) , $iHeight = _GDIPlus_ImageGetHeight($hBmp) , $iBgColor = 0x303030 ;$iBGColor format RRGGBB
Global $hGUI = GUICreate("GDI+ pixelate example", $iWidth, $iHeight) ;create a test GUI
GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
GUISetState()
;create buffered graphics frame set for smoother gfx object movements
Global Const $hBitmap = _WinAPI_CreateDIB($iWidth, $iHeight)
Global Const $hDC = _WinAPI_GetDC($hGUI)
Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC)
Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hBitmap)
Global Const $hGfxCtxt = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Local $hBitmap_new, $iFactor = 92
HotKeySet("{ESC}", "_Exit")
Do
For $i = $iFactor -1 To 1 Step - 1
$hBitmap_new = _GDIPlus_PixelateBitmap($hBmp, $i)
_GDIPlus_GraphicsDrawImageRect($hGfxCtxt, $hBitmap_new, 0, 0, $iWidth, $iHeight)
_GDIPlus_BitmapDispose($hBitmap_new)
_WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hDC_backbuffer, 0, 0, $SRCCOPY)
Next
Sleep(4000)
For $i = 1 To $iFactor
$hBitmap_new = _GDIPlus_PixelateBitmap($hBmp, $i)
_GDIPlus_GraphicsDrawImageRect($hGfxCtxt, $hBitmap_new, 0, 0, $iWidth, $iHeight)
;_GDIPlus_GraphicsDrawImageRect($hGfxCtxt, $hBitmap_new, 200, 200, $iWidth-400, $iHeight-400)
_GDIPlus_BitmapDispose($hBitmap_new)
_WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hDC_backbuffer, 0, 0, $SRCCOPY)
Next
Sleep(2000)
Until False ;sleep 2 s to avoid high cpu usage
EndFunc ;==>Example
Func _Exit()
;cleanup GDI+ resources
_GDIPlus_GraphicsDispose($hGfxCtxt)
_WinAPI_SelectObject($hDC, $DC_obj)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_ReleaseDC($hGUI, $hDC)
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
Exit
EndFunc ;==>_Exit
Func _GDIPlus_PixelateBitmap($hBitmap, $iPixelate = 9, $bSmooth = 1)
Local $iWidth = _GDIPlus_ImageGetWidth($hBitmap), $iHeight = _GDIPlus_ImageGetHeight($hBitmap)
Local $iNewW = Round($iWidth / $iPixelate, 0), $iNewH = Round($iHeight / $iPixelate, 0)
Local $hBitmap_scaled = _GDIPlus_BitmapCreateFromScan0($iNewW, $iNewH)
Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_scaled)
Local $iInterpolation = 5
If $bSmooth Then $iInterpolation = $GDIP_INTERPOLATIONMODE_BILINEAR
_GDIPlus_GraphicsSetInterpolationMode($hCtxt, $iInterpolation)
_GDIPlus_GraphicsDrawImageRect($hCtxt, $hBitmap, 0, 0, $iNewW, $iNewH)
_GDIPlus_GraphicsDispose($hCtxt)
Local $hBitmap_pixelated = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
$hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_pixelated)
_GDIPlus_GraphicsSetInterpolationMode($hCtxt, $GDIP_INTERPOLATIONMODE_NearestNeighbor)
_GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hBitmap_scaled, 0, 0, $iNewW, $iNewH, -$iPixelate, -$iPixelate, $iWidth + 2 * $iPixelate, $iHeight + 2 * $iPixelate)
_GDIPlus_GraphicsDispose($hCtxt)
Return $hBitmap_pixelated
Endfunc
;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2015-01-20
Func _Test_Image($bSaveBinary = False, $sSavePath = @ScriptDir)
Local $Test_Image
$Test_Image &= 'Code zu gross fürs Forum Komplettpaket als Anhang'
Local Const $bString = Binary(_WinAPI_Base64Decode($Test_Image))
If $bSaveBinary Then
Local Const $hFile = FileOpen($sSavePath & "\mood.jpg", 18)
If @error Then Return SetError(1, 0, 0)
FileWrite($hFile, $bString)
FileClose($hFile)
EndIf
Return $bString
EndFunc ;==>_Test_Image
Func _WinAPI_Base64Decode($sB64String)
Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
$aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
Return DllStructGetData($bBuffer, 1)
EndFunc ;==>_WinAPI_Base64Decode
Würde mich über Hilfe freuen
Tuxedo
Da das Script mit dem eingebetteten Code zu gross ist, hier nochmals als Dateianhang