Sure:
#include <Memory.au3>
#include <ScreenCapture.au3>
Example()
Func Example()
Local $hImage, $hImage2, $sCLSID, $tData, $tParams
If FileExists(@ScriptDir & "\GDIPlus_Image2.jpg") Then FileDelete(@ScriptDir & "\GDIPlus_Image2.jpg")
If FileExists(@ScriptDir & "\GDIPlus_Image.jpg") Then FileDelete(@ScriptDir & "\GDIPlus_Image.jpg")
; Capture screen
_ScreenCapture_Capture(@ScriptDir & "\GDIPlus_Image.jpg")
; Initialize GDI+ library
_GDIPlus_Startup()
; Load image
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\GDIPlus_Image.jpg")
$hImage2 = _GDIPlus_ImageResize($hImage, @DesktopWidth / 8, @DesktopHeight / 8, 7)
$hBitmap_Compressed = _GDIPlus_StreamImage2BinaryString($hImage2, "JPG", 100) ;converting back the memory bitmap to a JPG format
_GDIPlus_BitmapDispose($hImage2)
$hImage2 = _GDIPlus_BitmapCreateFromMemory($hBitmap_Compressed) ;load the JPG formatted image
; Get JPEG encoder CLSID
$sCLSID = _GDIPlus_EncodersGetCLSID("JPG")
; Set up parameters for 90 degree rotation
$tData = DllStructCreate("int Data;")
DllStructSetData($tData, "Data", $GDIP_EVTTRANSFORMROTATE90)
$tParams = _GDIPlus_ParamInit(1)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGTRANSFORMATION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Data"))
; Save image with rotation
_GDIPlus_ImageSaveToFileEx($hImage2, @ScriptDir & "\GDIPlus_Image2.jpg", $sCLSID, DllStructGetPtr($tParams))
; Shut down GDI+ library
_GDIPlus_Shutdown()
ShellExecute(@ScriptDir & "\GDIPlus_Image2.jpg")
EndFunc ;==>Example
Func _GDIPlus_StreamImage2BinaryString($hBitmap, $sFormat = "JPG", $iQuality = 80, $bSave = False, $sFilename = @ScriptDir & "\Converted.jpg") ;coded by UEZ 2013 build 2014-01-25
Local $sImgCLSID, $tGUID, $tParams, $tData
Switch $sFormat
Case "JPG"
$sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat)
$tGUID = _WinAPI_GUIDFromString($sImgCLSID)
$tData = DllStructCreate("int Quality")
DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100
Local $pData = DllStructGetPtr($tData)
$tParams = _GDIPlus_ParamInit(1)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
Case "PNG", "BMP", "GIF", "TIF"
$sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat)
$tGUID = _WinAPI_GUIDFromString($sImgCLSID)
Case Else
Return SetError(1, 0, 0)
EndSwitch
Local $hStream = _WinAPI_CreateStreamOnHGlobal() ;http://msdn.microsoft.com/en-us/library/ms864401.aspx
If @error Then Return SetError(2, 0, 0)
_GDIPlus_ImageSaveToStream($hBitmap, $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams))
If @error Then Return SetError(3, 0, 0)
Local $hMemory = _WinAPI_GetHGlobalFromStream($hStream) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx
If @error Then Return SetError(4, 0, 0)
Local $iMemSize = _MemGlobalSize($hMemory)
If Not $iMemSize Then Return SetError(5, 0, 0)
Local $pMem = _MemGlobalLock($hMemory)
$tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem)
Local $bData = DllStructGetData($tData, 1)
_WinAPI_ReleaseStream($hStream) ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221473(v=vs.85).aspx
_MemGlobalFree($hMemory)
If $bSave Then
Local $hFile = FileOpen($sFilename, 18)
If @error Then Return SetError(6, 0, $bData)
FileWrite($hFile, $bData)
FileClose($hFile)
EndIf
Return $bData
EndFunc ;==>_GDIPlus_StreamImage2BinaryString
Br,
UEZ