Search the Community
Showing results for tags 'gpiplus'.
-
Hey I was looking for methode to get the stream size of a picture from memory , wihtout need to write stream data to disk the then use filegetsize Thats what I am trying to do #include <gdiplus.au3> #include <memory.au3> #include <staticconstants.au3> _GDIPlus_Startup() Global $ghGDIPDLL = $__g_hGDIPDll While 1 $data = Desk_Stream(50) $data2 = StringSplit($data, "|") $My_Stream_Size = $data2[0] $My_Stream = $data2[1] ;. ;.. ;... Sleep(1000) WEnd _GDIPlus_Shutdown() Func Desk_Stream($Q) Local $hHBmp = _ScreenCapture_Capture("") ;create a GDI bitmap by capturing my desktop Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap Local $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap, @DesktopWidth / 2, @DesktopHeight / 2) ;resize image $sStream_Data = _GDIPlus_StreamImage2BinaryString($hBitmap_Scaled, $sQ, False, '') ;coded by UEZ 2013 build 2014-01-25; based on the code ;release resources otherwise memory leak _WinAPI_DeleteObject($hHBmp) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hBitmap_Scaled) Local $data_size = GetStreamSize($sStream_Data) Return $data_size & "|" & $sStream_Data EndFunc ;==>Desk_Stream Func _GDIPlus_StreamImage2BinaryString($hBitmap, $iQuality, $bSave, $sFilename) ;coded by UEZ 2013 build 2014-01-25; based on the code by Andreik Local $sImgCLSID, $tGUID, $tParams, $tData $sFormat = "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) 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) Return $bData EndFunc ;==>_GDIPlus_StreamImage2BinaryString Func GetStreamSize($data) ; ?? EndFunc