Hilfe bei GDIPlus gesucht

  • Hallo...

    Weiß jemand, wie man eine PNG-Datei auf einer Gui darstellt,
    wenn das PNG vorher in einer Variable abgelegt ist?

    Das Anzeigen klappt wunderbar, wenn das PNG als Datei vorliegt.
    Also z.b. so: (hatte ich irgendwo aus dem Forum her)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit]

    Func _Display_PNG ()
    Local Const $STM_SETIMAGE = 0x0172
    _GDIPlus_Startup ()
    Local $ImageLoad = _GDIPlus_BitmapCreateFromFile (@ScriptDir & "\Test.png")
    Local $ImageHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($ImageLoad)
    GUICtrlSendMsg ($ShowPNG, $STM_SETIMAGE, 0, $ImageHandle)
    _WinAPI_DeleteObject ($ImageHandle)
    _GDIPlus_BitmapDispose ($ImageLoad)
    _GDIPlus_Shutdown ()
    EndFunc

    [/autoit]

    Ich lese das PNG aus einem Profil aus (mit _HexRead, hab ich aus dem englischen Forum, wo es eingebettet ist...
    Würde mir den Umweg gern ersparen, das PNG erst zu speichern (liegt ja bereits als Variable vor)
    und es dann wieder einzulesen...

    Müßte doch evtl. mit GDIPlus möglich sein, die Variable direkt zu nutzen... Oder?

    Kenne mich mir GDIPlus nicht aus, und wäre über eure Hilfe sehr erfreut..

    MfG Diggidie

    2 Mal editiert, zuletzt von Diggidie (9. Februar 2013 um 14:50) aus folgendem Grund: Weitere Funktion gesucht, deshalb wieder geöffnet...

  • Hier mal ein lauffähiges Script zum nachvollziehen (benötigt die "TestDatei.7z" aus dem Anhang im Script-Verzeichnis)

    Spoiler anzeigen
    [autoit]

    ;############################################################################################################
    ;## Schritt 1 = _HexRead extrahiert das PNG aus der Test-Datei und speichert es in der Variable $PNG_Lesen ##
    ;## Schritt 2 = Das PNG-Bild, also die Variable $PNG_Lesen, wird gespeichert ##
    ;## Schritt 3 = Das PNG-Bild wird geladen und angezeigt mit _Display_PNG ##
    ;## Problem = Möchte das speichern und einlesen vermeiden, sondern direkt die Variable $PNG_Lesen nutzen ##
    ;############################################################################################################

    [/autoit] [autoit][/autoit] [autoit]

    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $PNG_Lesen = _HexRead (@ScriptDir & "\TestDatei.7z", 0x110A, 0x0165); 0x110A = Position des PNG, 0x0165 = Länge der PNG-Datei in der TestDatei.blabla
    $PNG_Datei = FileOpen (@ScriptDir & "\Test.png", 14); möchte ich umgehen
    FileWrite ($PNG_Datei, $PNG_Lesen); möchte ich umgehen
    FileClose ($PNG_Datei); möchte ich umgehen

    [/autoit] [autoit][/autoit] [autoit]

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit]

    Func _Display_PNG ()
    Local Const $STM_SETIMAGE = 0x0172
    _GDIPlus_Startup ()
    Local $ImageLoad = _GDIPlus_BitmapCreateFromFile (@ScriptDir & "\Test.png"); Hier würde ich gern irgendwie die $PNG_Lesen Variable nutzen
    Local $ImageHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($ImageLoad)
    GUICtrlSendMsg ($ShowPNG, $STM_SETIMAGE, 0, $ImageHandle)
    _WinAPI_DeleteObject ($ImageHandle)
    _GDIPlus_BitmapDispose ($ImageLoad)
    _GDIPlus_Shutdown ()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _HexRead($FilePath, $Offset, $Length)
    Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos
    If Not FileExists($FilePath) Then Return SetError(1, @error, 0)
    $fLen = FileGetSize($FilePath)
    If $Offset > $fLen Then Return SetError(2, @error, 0)
    If $fLen < $Offset + $Length Then Return SetError(3, @error, 0)
    $Buffer = DllStructCreate("byte[" & $Length & "]")
    $ptr = DllStructGetPtr($Buffer)
    $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0)
    If $hFile = 0 Then Return SetError(5, @error, 0)
    $Pos = $Offset
    $Result = _WinAPI_SetFilePointer($hFile, $Pos)
    $err = @error
    If $Result = 0xFFFFFFFF Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(6, $err, 0)
    EndIf
    $Read = 0
    $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read)
    $err = @error
    If Not $Result Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(7, $err, 0)
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not $Result Then Return SetError(8, @error, 0)
    $Result = DllStructGetData($Buffer, 1)
    Return $Result
    EndFunc

    [/autoit]


    Der Anhang ist keine 7zip Datei, muß also nicht entpackt werden, upload wollte eine Dateiendung haben...
    Die angehängte Datei enthält nur 0x00'en und ein eingebettetes PNG-Bild, welches mit _HexRead ausgelesen wird...

    Mir geht es nun darum die Variable $PNG_Lesen direkt anzeigen zu lassen,
    also ohne den Umweg, wie im Script, mit dem speichern und neu einlesen des PNG...
    Der Weg wie im Script mit dem speichern klappt ja, benötige nur dringend eine Variante ohne speichern des PNG...

    Lg Diggidie

    Einmal editiert, zuletzt von Diggidie (3. Februar 2013 um 23:40) aus folgendem Grund: Test-Datei angehängt und lauffähiges Script zum testen eingefügt

  • Danke UAZ...
    Bekomme Dein Script zwar nicht zum laufen, aber beim durchsehen Deiner Source
    bin ich auf die "Load_BMP_From_Mem"-Funktion gestoßen :)
    Funktioniert, aber weiß nicht genau, ob das PNG nach dem anzeigen wieder
    aus dem Speicher gelöscht wird... (wie gesagt, kein Plan von GDIPlus)
    Könnte mir auch sehr gut vorstellen, das ich überflüssige Dinge mir eingebaut habe :(
    Könnte evtl. jemand das Script mal durchsehen und vielleicht auch dementsprechend anpassen?

    Hier das lauffähige Script, wo das PNG aus dem Speicher angezeigt wird, Anhang aus Post 2 wird benötigt...

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Memory.au3>
    $PNG_Lesen = _HexRead (@ScriptDir & "\TestDatei.7z", 0x110A, 0x0165); 0x110A = Position des PNG, 0x0165 = Länge der PNG-Datei in der TestDatei.blabla

    [/autoit] [autoit][/autoit] [autoit]

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit]

    Func _Display_PNG ()
    Local Const $STM_SETIMAGE = 0x0172
    _GDIPlus_Startup ()
    $PNG_from_Mem = Load_BMP_From_Mem($PNG_Lesen)
    Local $ImageHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($PNG_from_Mem)
    GUICtrlSendMsg ($ShowPNG, $STM_SETIMAGE, 0, $ImageHandle)
    _WinAPI_DeleteObject ($ImageHandle)
    _GDIPlus_Shutdown ()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;======================================================================================
    ; Function Name: Load_BMP_From_Mem
    ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
    ;
    ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+
    ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created
    ;
    ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
    ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
    ;
    ; Requirement(s): GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
    ; Error: 0
    ; Error codes: 1: $bImage is not a binary string
    ; 2: unable to create stream on HGlobal
    ; 3: unable to create bitmap from stream
    ;
    ; Author(s): UEZ
    ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
    ; Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Version: v0.98 Build 2012-08-29 Beta
    ;=======================================================================================
    Func Load_BMP_From_Mem($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
    "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
    Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hHBmp
    EndIf
    Return $hBitmap
    EndFunc ;==>Load_BMP_From_Mem

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate( 'dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/…1(v=vs.85).aspx
    'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;' & _
    'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
    'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
    'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
    DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
    $hResult = $hResult[0]
    Else
    $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
    EndFunc ;==>_WinAPI_BitmapCreateDIBFromBitmap

    [/autoit] [autoit][/autoit] [autoit]

    Func _HexRead($FilePath, $Offset, $Length)
    Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos
    If Not FileExists($FilePath) Then Return SetError(1, @error, 0)
    $fLen = FileGetSize($FilePath)
    If $Offset > $fLen Then Return SetError(2, @error, 0)
    If $fLen < $Offset + $Length Then Return SetError(3, @error, 0)
    $Buffer = DllStructCreate("byte[" & $Length & "]")
    $ptr = DllStructGetPtr($Buffer)
    $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0)
    If $hFile = 0 Then Return SetError(5, @error, 0)
    $Pos = $Offset
    $Result = _WinAPI_SetFilePointer($hFile, $Pos)
    $err = @error
    If $Result = 0xFFFFFFFF Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(6, $err, 0)
    EndIf
    $Read = 0
    $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read)
    $err = @error
    If Not $Result Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(7, $err, 0)
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not $Result Then Return SetError(8, @error, 0)
    $Result = DllStructGetData($Buffer, 1)
    Return $Result
    EndFunc

    [/autoit]

    MfG Diggidie

  • Nochmals Danke UEZ (Sorry für's A statt dem E vorhin :whistling: )

    Dein erstes Beispiel hat mir die Lösung gebracht... :thumbup: (hoffe ich zumindest)

    Hier das fertige Beispiel, sollte so funktionieren... (Anhang aus Post 2 wird benötigt... )

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Memory.au3>
    Global Const $IMAGE_BITMAP = 0
    Global Const $STM_SETIMAGE = 0x0172

    [/autoit] [autoit][/autoit] [autoit]

    $PNG_Lesen = _HexRead (@ScriptDir & "\TestDatei.7z", 0x110A, 0x0165); 0x110A = Position des PNG, 0x0165 = Länge der PNG-Datei in der TestDatei.blabla

    [/autoit] [autoit][/autoit] [autoit]

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit]

    Func _Display_PNG ()
    _GDIPlus_Startup ()
    $PNG_from_Mem = Load_BMP_From_Mem($PNG_Lesen, True)
    _WinAPI_DeleteObject(GUICtrlSendMsg($ShowPNG, $STM_SETIMAGE, $IMAGE_BITMAP, $PNG_from_Mem))
    _GDIPlus_Shutdown ()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;======================================================================================
    ; Function Name: Load_BMP_From_Mem
    ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
    ;
    ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+
    ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created
    ;
    ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
    ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
    ;
    ; Requirement(s): GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
    ; Error: 0
    ; Error codes: 1: $bImage is not a binary string
    ; 2: unable to create stream on HGlobal
    ; 3: unable to create bitmap from stream
    ;
    ; Author(s): UEZ
    ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
    ; Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Version: v0.98 Build 2012-08-29 Beta
    ;=======================================================================================
    Func Load_BMP_From_Mem($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
    "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
    Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hHBmp
    EndIf
    Return $hBitmap
    EndFunc ;==>Load_BMP_From_Mem

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate( 'dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/…1(v=vs.85).aspx
    'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;' & _
    'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
    'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
    'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
    DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
    $hResult = $hResult[0]
    Else
    $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
    EndFunc ;==>_WinAPI_BitmapCreateDIBFromBitmap

    [/autoit] [autoit][/autoit] [autoit]

    Func _HexRead($FilePath, $Offset, $Length)
    Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos
    If Not FileExists($FilePath) Then Return SetError(1, @error, 0)
    $fLen = FileGetSize($FilePath)
    If $Offset > $fLen Then Return SetError(2, @error, 0)
    If $fLen < $Offset + $Length Then Return SetError(3, @error, 0)
    $Buffer = DllStructCreate("byte[" & $Length & "]")
    $ptr = DllStructGetPtr($Buffer)
    $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0)
    If $hFile = 0 Then Return SetError(5, @error, 0)
    $Pos = $Offset
    $Result = _WinAPI_SetFilePointer($hFile, $Pos)
    $err = @error
    If $Result = 0xFFFFFFFF Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(6, $err, 0)
    EndIf
    $Read = 0
    $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read)
    $err = @error
    If Not $Result Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(7, $err, 0)
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not $Result Then Return SetError(8, @error, 0)
    $Result = DllStructGetData($Buffer, 1)
    Return $Result
    EndFunc

    [/autoit]

    MfG Diggidie

  • Die Datei im Anhang ist korrupt.

    Gruß,
    UEZ

    Hallo UEZ,

    die Datei ist nicht korrupt ;)
    Hatte extra unter dem Spoiler in Post 2 folgendes geschrieben:

    Der Anhang ist keine 7zip Datei, muß also nicht entpackt werden, upload wollte eine Dateiendung haben...

    Die angehängte Datei enthält nur 0x00'en und ein eingebettetes PNG-Bild, welches mit _HexRead ausgelesen wird...

    Kann gern mit einem Hex-Editor überprüft werden...

    MfG Diggidie

  • Um das Bild aus dem Speicher zu laden:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Memory.au3>
    Global Const $IMAGE_BITMAP = 0
    Global Const $STM_SETIMAGE = 0x0172

    [/autoit] [autoit][/autoit] [autoit]

    $PNG_Lesen = _Test_PNG()

    [/autoit] [autoit][/autoit] [autoit]

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit]

    Func _Display_PNG ()
    _GDIPlus_Startup ()
    $PNG_from_Mem = Load_BMP_From_Mem($PNG_Lesen, True)
    _WinAPI_DeleteObject(GUICtrlSendMsg($ShowPNG, $STM_SETIMAGE, $IMAGE_BITMAP, $PNG_from_Mem))
    _WinAPI_DeleteObject($PNG_from_Mem)
    _GDIPlus_Shutdown ()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;======================================================================================
    ; Function Name: Load_BMP_From_Mem
    ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
    ;
    ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+
    ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created
    ;
    ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
    ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
    ;
    ; Requirement(s): GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
    ; Error: 0
    ; Error codes: 1: $bImage is not a binary string
    ; 2: unable to create stream on HGlobal
    ; 3: unable to create bitmap from stream
    ;
    ; Author(s): UEZ
    ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
    ; Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Version: v0.98 Build 2012-08-29 Beta
    ;=======================================================================================
    Func Load_BMP_From_Mem($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
    "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
    Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hHBmp
    EndIf
    Return $hBitmap
    EndFunc ;==>Load_BMP_From_Mem

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate( 'dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/…1(v=vs.85).aspx
    'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;' & _
    'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
    'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
    'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
    DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
    $hResult = $hResult[0]
    Else
    $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
    EndFunc ;==>_WinAPI_BitmapCreateDIBFromBitmap

    [/autoit] [autoit][/autoit] [autoit]

    ;Code below was generated by: 'File to Base64 String' Code Generator v1.11 Build 2012-10-13

    [/autoit] [autoit][/autoit] [autoit]

    Func _Test_PNG($bSaveBinary = False)
    Local $Test_PNG
    $Test_PNG &= 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAGFBMVEX+/v6Pj486OjoyMjIlJSVbW1vHx8fe3t6Fwq2EAAABCElEQVR42uyX6xKEIAiFQUDf/43Xyku1aSzuzDY7nn9mfCkeqIDcmIBpSI8BsE0VYMtfBbgJ+G+ARNkBGGBVQDEACGEnLx8DAhyFHwLO8VeEDoA8vEvOpdwGkJS9+7oUrwdwTr+LRV9g4LSAeHXT1miktYcmgNMJ4nZbXk8a3wOI/X7JnIdaQJxIjyQDIIWwE8R0Pzt1DupM7rnroHji5hhbjb/UBPYA7RdHaNpgD2jGS8fJGkA3XgEoFoIgZABUE+P1vBogbARgN14PaKVYC/B2gPhFaAccasLiA+rGKwAI3SyqT2ECfgpYWjOW9mx2Ig84sa8JmICvAGj0c/9Rf65DgDHRS4ABAEawKhSQsN92AAAAAElFTkSuQmCC'
    Local $bString = Binary(_Base64Decode($Test_PNG))
    If $bSaveBinary Then
    Local $hFile = FileOpen(@ScriptDir & "\Test.png", 18)
    FileWrite($hFile, $bString)
    FileClose($hFile)
    EndIf
    Return $bString
    EndFunc ;==>_Test_PNG

    [/autoit] [autoit][/autoit] [autoit]

    Func _Base64Decode($sB64String)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $sB64String, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $sB64String, "int", 0, "int", 1, "ptr", DllStructGetPtr($a), "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($a, 1)
    EndFunc ;==>_Base64Decode

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Möchte das Thema nochmal öffnen, weil ich noch eine weitere Funktion benötige, und ein
    neues Thema evtl. nicht angebracht wäre...

    Wie stelle ich es an, nachdem die Gui aufgebaut ist und die Grafik angezeigt wird, und
    ich dann mit dem Mauszeiger über die Grafik fahre, das die Grafik in doppelter Größe
    angezeigt wird???

    Kurz: Mauszeiger auf Grafik --> Grafik vergrößert sich --> Mauszeiger von Grafik --> Grafik verkleinert sich wieder
    (und da kommt bestimmt wieder GDIPlus ins Spiel, wo ich gar nicht durchsteige)

    Hier noch mal das Script und die Testdatei:
    (Der Anhang ist keine 7zip Datei, muß also nicht entpackt werden, upload wollte eine Dateiendung haben...
    Die angehängte Datei enthält nur 0x00'en und ein eingebettetes PNG-Bild, welches mit _HexRead ausgelesen wird...
    Kann gern mit einem Hex-Editor überprüft werden...)

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Memory.au3>
    Global Const $IMAGE_BITMAP = 0
    Global Const $STM_SETIMAGE = 0x0172

    [/autoit] [autoit][/autoit] [autoit]

    $PNG_Lesen = _HexRead (@ScriptDir & "\TestDatei.7z", 0x110A, 0x0165); 0x110A = Position des PNG, 0x0165 = Länge der PNG-Datei in der TestDatei.blabla

    [/autoit] [autoit][/autoit] [autoit]

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit]

    Func _Display_PNG ()
    _GDIPlus_Startup ()
    $PNG_from_Mem = Load_BMP_From_Mem($PNG_Lesen, True)
    _WinAPI_DeleteObject(GUICtrlSendMsg($ShowPNG, $STM_SETIMAGE, $IMAGE_BITMAP, $PNG_from_Mem))
    _GDIPlus_Shutdown ()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;======================================================================================
    ; Function Name: Load_BMP_From_Mem
    ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
    ;
    ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+
    ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created
    ;
    ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
    ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
    ;
    ; Requirement(s): GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
    ; Error: 0
    ; Error codes: 1: $bImage is not a binary string
    ; 2: unable to create stream on HGlobal
    ; 3: unable to create bitmap from stream
    ;
    ; Author(s): UEZ
    ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
    ; Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Version: v0.98 Build 2012-08-29 Beta
    ;=======================================================================================
    Func Load_BMP_From_Mem($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
    "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
    Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hHBmp
    EndIf
    Return $hBitmap
    EndFunc ;==>Load_BMP_From_Mem

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate( 'dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/…1(v=vs.85).aspx
    'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;' & _
    'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
    'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
    'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
    DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
    $hResult = $hResult[0]
    Else
    $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
    EndFunc ;==>_WinAPI_BitmapCreateDIBFromBitmap

    [/autoit] [autoit][/autoit] [autoit]

    Func _HexRead($FilePath, $Offset, $Length)
    Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos
    If Not FileExists($FilePath) Then Return SetError(1, @error, 0)
    $fLen = FileGetSize($FilePath)
    If $Offset > $fLen Then Return SetError(2, @error, 0)
    If $fLen < $Offset + $Length Then Return SetError(3, @error, 0)
    $Buffer = DllStructCreate("byte[" & $Length & "]")
    $ptr = DllStructGetPtr($Buffer)
    $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0)
    If $hFile = 0 Then Return SetError(5, @error, 0)
    $Pos = $Offset
    $Result = _WinAPI_SetFilePointer($hFile, $Pos)
    $err = @error
    If $Result = 0xFFFFFFFF Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(6, $err, 0)
    EndIf
    $Read = 0
    $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read)
    $err = @error
    If Not $Result Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(7, $err, 0)
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not $Result Then Return SetError(8, @error, 0)
    $Result = DllStructGetData($Buffer, 1)
    Return $Result
    EndFunc

    [/autoit]

    MfG Diggidie