Jump to content

8 bit png stored as binary string in script


Recommended Posts

Cant get this to work, i want to HBITMAP_To_Bytes an 8bit png image and store it as binary string in the script, then xor or invert it with another image later on but i cant get it to even show up on gui, i also tried an example image but no luck,  not even an example gif image i got from the forum

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <Memory.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

#include <StaticConstants.au3>
AutoItSetOption("GUIOnEventMode", 1)

$Width = @DesktopWidth / 2
$Height = @DesktopHeight / 2
$Form = GUICreate("GUI", $Width, $Height, -1, -1, $WS_MINIMIZEBOX+ $WS_CAPTION+ $WS_POPUP+ $WS_SYSMENU+$WS_SIZEBOX)
$Pic = GUICtrlCreatePic("", 0, 0, 255, 255)
GUICtrlSetResizing($Pic, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
GUISetState(@SW_SHOW)

$hCtrl = GUICtrlGetHandle($Pic) ;get the $Pic ctrl handle
$hGUI_DC = _WinAPI_GetDC($hCtrl)

Local $hWnd = _WinAPI_GetDesktopWindow()
Local $hDDC = _WinAPI_GetDC($hWnd)

Local $Bmp_DibHandle
Local $Bmp_DibHandleObj
Local $Bmp_ptr
Local $Bmp_Buffer = _CreateNewDIB_Bitmap(100, 100,8,$Bmp_ptr,$Bmp_DibHandle,$Bmp_DibHandleObj)
_WinAPI_SetStretchBltMode($Bmp_Buffer, $COLORONCOLOR)


Local $sBinGIFImage = '0x47494638396144004700F70000FFFFFF1831711C357D182D6D1C3982182D691C35791C3986CACACA1831751C3D9614246118316D14286914357D1835791C398A183575204192142D65C2C2C2BE9296142459203D92AEAAAEC69A9AB2B2B6BAB6B6CACACEBEAA41142D7520398A395D9618358614317DA29E9E1028751C3D8A0C2455797979A27D7918316941699ECEA2A23D4955101C4955595961656100041C86828214358E182861B6A23DEBEBEBBEBEBE142D71E7B2B220419EB28E8E10246D2D3959DFA6AA10245D8E8A8EA29641696969CAB241202D49082065C6C6CA0C1C516165556979927D61616186B2183179AAAAAAC6C6C2969296DBDBDF243D718A71712031591C3582DFAEAE8E7D86A2A6A6314579866969AA828214285D20316910246592928E1031860410353D5D92F3F3F328499A14399A14203D3539497D754986868E0C2059A28282E3E3E3081024AE9A3D967171454545355992494D61AE8A8E7175797D869ED7A2A26555554D4D51B69296DBD7D7394969928A4D555D65D7A6AA8A7D39142855CAA6AA203982EBCACE5D6569AE9A359E9E9E715959183161B6C2DF5186C22D4169928A55414965BABABE615971AE9E9E0C18394559755979AAEBE3DF31498A5179A22439694159A6313128A6964D9EAABEDFBABE314982514924081849495565A696396969610C287D4535352035719682867171557171694571A64D5D861C3D92D2BE41514141DBCACAEFB6BA49393D24459A315586394561082471C6B649614D55B6AA5D1C2D59BE969A3D49717D7959614949CAB2AE514139244186E3C6CAF3EFEB756935797965867D55595D4561758AFBBEC23D659A1C357161551CBAAA49413D456D798A7D8282617DA2141C35000C2820283D24418A79753DE3DFDB24395D9692695D6986283965B2B2B23559968A8279FBFBEF8692AEEFD74D516D96C6B6559A8E45353541A69E5D82615D967D79454531D2BE4D92864561869E14244D554D456D6555393D555D61613159A6B286867592B29E8A351C316DF7FBFBFFC6C665757D1C397D555D7DCECACA1C3979182D71BEC2CE4539206D611C866561FFFFFF21F904010000FF002C00000000440047000008FF00FF091C48B0A0C18308132A5CC8B0A1C38710233E74674CA2C58B08C5E4B8900F16C68F1651697C152011C8930E977DD3A6F100CA970BC5C9C92166D92431307316540149C2AB1CDE64EA1CFA2FDA87483968CE01878E684E246A7E591A9369DBBE664E5F669254E357264BD3BAE2819715243C0A3FAA90DA45CF519518562894FDA8A451851E3DA8E0C0DBA34D3D25733156A0A32990AFC281FED02115F862333AACE6593A24F550183EB71A5BAC42C7579843785A1D7A52435306249A1F12BB1567452B568134E10864184706478C5333248645C70A3E545A151BDE8A'
$sBinGIFImage &= '0F9F0C59C645D2BD70CE381D192A00C7419DCA0AE851A200669E905B1B1D59A264FFD171A7C29D3869B0544893663BF7834AD2E878A7AE1096FB5892D4D185FCC77B8555E8E0883AAEF0B2CA81AE8812C31F59CCF15F4255E013060241ACE2CA856E7451430DBBA0F6E0418CFC5243183570D0055C4F90D855261F1AC44D586AE0F1C4346AA8F1C41378C818A3832D0E840D1E1C144101214EFC10430C4E60C0880D08E063458F0229C10436D830614A21B75041051F59D47186154C6060857B1FCE51A413419CB0CB1F155470CB1F8EB473C20F3F10D2548F679C70423B31E0C301051B6CC008051CD810449A319C01A529EDB8C00C0708441A24A44D3212840B413003252EE198B2411191861AAA9056B4C303253D9E3204343130C108A8A246FF4A81065604F185212DBA13CB258F04E1043636C03A2A234CFCA0CC1A5FE4F3E03DB598334B1F6EC44008B0C2526003064E9832C4140494100D18DCF522432DDD74534D19A074C1C4061414E1AE0DD88C10831B054860EF0507BC919A0AD1C880CA37D598730509653033EDA0D6128BE6B6537C7081BD074CD258360294708135937821483B32D8F282BA1BD8400123D8101283324B8883CB14164B700104F69C52960A0F5C60732A1008E0413E071C50C60907DBB001B62E4C708F399E784080C33643207156BD9470EF070404208F008094F0801D203342EB093CC8608A397AA4B0440810A4F28A045364E3943153D82B412A5E3CD04002F6007240098604FF31ED06D83861C703105C318B10476CB1C726D5D4A3C0058038958FD46B07014A0A2CE0220001807C00010F3160808D152FC853C20121E4A20A382C60924C300AACDDF650F55CA1B602F5D4D2411FEB94620FE77B2F01C70818FCC043CF3D8B20CCEE8360E2F0BDBDE8D40C2EA9DC1B0D208B00B345289BEBBD770A273001C7143D0302880022E4314C1F1D4002814F1240103D4C9BBC7F2F014B7051C60D09189037F221488420187000F3018200F610C0120AE086580822040FB3D71440F01228340010AF78C5053E20007DF8410AFA08C0037EE73DADF9E0000448E10113688014A4C30709C89A4F2E20002D80EB24D780C11A5A6080541CC00033184201FF18C0800808200421F0DE01A7600F6EA590850C68413A182000089460028F58C31A6E884318E8900706F0C0AA0650800124E00182B84212CD470001B8F1776D34C00306E087474CE0015080C61A74C8459424E20BCEE045387CD0023F04A000050880084C910C35AED08D6E4CA1000C60802D68E11146B0052F44B10632F4112588384521508002657CA100FA2840031409095528220492A42424DD28823DB8800B8F20C328DB0087ACB4860A7480430306708D44DC2014B998C52C1E294B01E4037DA1D0830B88900E72E0E0388A220A12B290811564200EF220A6191251'
$sBinGIFImage &= '8A0ECC2219BF73A32C45100C458002141D580711E0E0CD1554801CA81A0A12DE91FF810CD4E116A318C004A4C1860E744008C110813A2949497B2842151DA0011086D18834446105B7408153908002D69021035018400358400321084118906428431F600045449406D2684414D8B18238A0603943B1863FB2F38524E0A2003358C0223CE10903A4F4014865E812842104894A610FEC18421AFC5108A750A20E3B8506341800542D34C0032260E94A2380D40788E00542D0831ED8C0834E7CA10EE4488237B2428946D022099C40A416B45080049075AC11202B4BDBF182048C420F7048072D0AA18BB9CEC50EC0E0C43576E003BE06E0AF728C4002361BD80878C00309F040256231047570E21E8808CC30E2818C3E9881053E48A45FCBBAD900FF6CF6B6B5D5470386800C7E78642E8860413FFAF00970B821B60CB02D529790800038D7B9B7752E5787C08974FC762E9740C627CEB10534F035B99BBD022E3C10007DDCE0B9CF256201A4A08E4E5C372B60E0871DCC30081E547688B6F5401E30510912546211E7452F03C8A88572E432302A4807170A60063BA0C102654CAE7E69908B2300C11301962E570B5060673C2230C630C1041A90026A5800C22918803E46E10920B08106A5B80111931B00F572D80816480788455C8009CCC0027C2D803C4A01840EB0E1C87990F18C67ACD774580057733184052640E519F821C80CA8C41ECC70641A80A312FA604098990CD47418410B08DEEB0C66A0852B237269C0B258041BCE710433B840C9649E409BAFA002CDC0020A50D0420BA6FCE61BC0810D89D8C10EE4B1641B4FC0022A482D734E01060BC416913758443B1AA0CA05AC79060D6840507D9082147C48056F28B53C183D80141862132088B5AC63FD069941E9D6B84E484000003B'
Binary($sBinGIFImage)


    ;TEst x
    Local $Bmp_Buffer2 = _WinAPI_CreateCompatibleDC(0)
    $hHBITMAP = Load_BMP_From_Mem($sBinGIFImage, True)
    _WinAPI_SelectObject($Bmp_Buffer2, $hHBITMAP)


    ;Test y
    Local $hBitmap = _GDIPlus_BitmapCreateFromMemory($sBinGIFImage) ;load binary saved GIF image and convert it to GDI+ bitmap format
    ;ok now what, how do i get it to be gdi bitmap so i can _WinAPI_BitBlt it?




    _WinAPI_BitBlt($Bmp_Buffer, 0, 0, $Width, $Height, $Bmp_Buffer2, 0, 0,$NOTSRCCOPY ) ;Invert color
    _WinAPI_BitBlt($Bmp_Buffer, 0, 0, $Width, $Height, $Bmp_Buffer, 0, 0,$SRCINVERT) ;Invert color
    _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $Bmp_Buffer, 0, 0,$SRCCOPY  ) ;Invert color
    sleep(2000)

    _GDIPlus_ImageSaveToFile($Bmp_Buffer, "InvertedAndXored.png")

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

While 1

WEnd



func _Exit()
    Exit
EndFunc




;======================================================================================
; Function Name:        Load_BMP_From_Mem
; Description:          Loads a image which is saved as a binary string and converts it to a bitmap or hbitmap
;
; Parameters:           $mem_image:     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
;
; Requirement(s):       GDIPlus.au3, Memory.au3
; Return Value(s):  Success: handle to bitmap or hbitmap, Error: 0
; Error codes:          1: $mem_image is not a binary string
;
; Author(s):                UEZ
; Additional Code:  thanks to progandy for the MemGlobalAlloc and tVARIANT lines
; Version:                  v0.95 Build 2011-06-11 Beta
;=======================================================================================
Func Load_BMP_From_Mem($mem_image, $hHBITMAP = False)
If Not IsBinary($mem_image) Then Return SetError(1, 0, 0)
Local $declared = True
If Not $__g_hGDIPDll Then
_GDIPlus_Startup()
$declared = False
EndIf
Local Const $memBitmap = Binary($mem_image) ;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
Local $hStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0)
$hStream = $hStream[3]
Local $hBitmap = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
$hBitmap = $hBitmap[2]
Local Const $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
If $hHBITMAP Then
Local Const $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
If Not $declared Then _GDIPlus_Shutdown()
Return $hHBmp
EndIf
If Not $declared Then _GDIPlus_Shutdown()
Return $hBitmap
EndFunc   ;==>Load_BMP_From_Mem

Func _CreateNewDIB_Bitmap($Width, $Height,$BitCount, ByRef $ptrbmp, ByRef $DibHandle, ByRef $DibHandle_Obj)

    Local $tBITMAPINFO = DllStructCreate("dword Size; long Width; long Height; word Planes; word BitCount; dword Compression; dword SizeImage; long XPelsPerMeter; long YPelsPerMeter; dword ClrUsed; dword ClrImportant; dword RGBQuad[256];")
    DllStructSetData($tBITMAPINFO, 'Size', 40)
    DllStructSetData($tBITMAPINFO, 'Width', $Width)
    DllStructSetData($tBITMAPINFO, 'Height', -$Height)
    DllStructSetData($tBITMAPINFO, 'Planes', 1)
    DllStructSetData($tBITMAPINFO, 'BitCount', $BitCount)
    Local $iColorCnt = BitShift(1, -$BitCount)
    DllStructSetData($tBITMAPINFO, 'ClrUsed', $iColorCnt)
    DllStructSetData($tBITMAPINFO, 'ClrImportant', $iColorCnt)
    Switch $BitCount
        Case 1
            DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift(0xFF, -16), BitShift(0xFF, -8), 0xFF), 2)
        Case 4
            Local $aCol[16] = [8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248]
            For $i = 0 To 15
                DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1)
            Next
        Case 8
        ; Windows reserves first color for white,
            $tBITMAPINFO.RGBQuad((0)) = 0xFFFFFF
            ; and last color as black!
            $tBITMAPINFO.RGBQuad((0xFF)) = 0x000000

            Local $iColor = 20, $iRed, $iGreen, $iBlue
            For $iRed = 0 To 255 Step 51
                For $iGreen = 0 To 255 Step 51
                    For $iBlue = 0 To 255 Step 51
                        $tBITMAPINFO.RGBQuad(($iColor)) = BitShift($iRed, -16) + BitShift($iGreen, -8) + $iBlue
                        $iColor += 1
                    Next
                Next
            Next

    EndSwitch

    Local $hDCbuffer = _WinAPI_CreateCompatibleDC(0)
    $DibHandle = _WinAPI_CreateDIBSection(0, $tBITMAPINFO, $DIB_RGB_COLORS, $ptrbmp)
;~  $DibHandle = _WinAPI_CreateDIBSection(0,  $tBMI, $DIB_RGB_COLORS, $ptrbmp)
    $DibHandle_Obj=_WinAPI_SelectObject($hDCbuffer, $DibHandle)
    Return $hDCbuffer
EndFunc   ;==>_CreateNewDIB_Bitmap


Func HBITMAP_To_Bytes($HBITMAP)
    _GDIPlus_Startup()
    Local $BITMAP = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP)
    Local $JPG_ENCODER = _GDIPlus_EncodersGetCLSID("png")
    Local $TAG_ENCODER = _WinAPI_GUIDFromString($JPG_ENCODER)
    Local $PTR_ENCODER = DllStructGetPtr($TAG_ENCODER)
    Local $STREAM = DllCall("ole32.dll","uint","CreateStreamOnHGlobal","ptr",0,"bool",1,"ptr*",0)
    DllCall($__g_hGDIPDll,"uint","GdipSaveImageToStream","ptr",$BITMAP,"ptr",$STREAM[3],"ptr",$PTR_ENCODER,"ptr",0)
    _GDIPlus_BitmapDispose($BITMAP)
    Local $MEMORY = DllCall("ole32.dll","uint","GetHGlobalFromStream","ptr",$STREAM[3],"ptr*",0)
    Local $MEM_SIZE = _MemGlobalSize($MEMORY[2])
    Local $MEM_PTR = _MemGlobalLock($MEMORY[2])
    Local $DATA_STRUCT = DllStructCreate("byte[" & $MEM_SIZE & "]", $MEM_PTR)
    Local $DATA = DllStructGetData($DATA_STRUCT,1)
    _MemGlobalFree($MEMORY[2])
    _GDIPlus_Shutdown()
    Return $DATA
EndFunc

 

Link to comment
Share on other sites

To use GDI+ functions you must call _GDIPlus_Startup() before you can use any GDI+ function. Further Load_BMP_From_Mem() is already integrated to the GDI+ UDF and it's called _GDIPlus_BitmapCreateFromMemory().

Try something like this here:

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <Memory.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

#include <StaticConstants.au3>
AutoItSetOption("GUIOnEventMode", 1)

$Width = @DesktopWidth / 2
$Height = @DesktopHeight / 2
$hGUI = GUICreate("GUI", $Width, $Height, -1, -1, $WS_MINIMIZEBOX+ $WS_CAPTION+ $WS_POPUP+ $WS_SYSMENU+$WS_SIZEBOX)
$Pic = GUICtrlCreatePic("", 0, 0, 255, 255)
GUICtrlSetResizing($Pic, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
GUISetState(@SW_SHOW)

$hCtrl = GUICtrlGetHandle($Pic) ;get the $Pic ctrl handle
$hGUI_DC = _WinAPI_GetDC($hCtrl)

Local $sBinGIFImage = '0x47494638396144004700F70000FFFFFF1831711C357D182D6D1C3982182D691C35791C3986CACACA1831751C3D9614246118316D14286914357D1835791C398A183575204192142D65C2C2C2BE9296142459203D92AEAAAEC69A9AB2B2B6BAB6B6CACACEBEAA41142D7520398A395D9618358614317DA29E9E1028751C3D8A0C2455797979A27D7918316941699ECEA2A23D4955101C4955595961656100041C86828214358E182861B6A23DEBEBEBBEBEBE142D71E7B2B220419EB28E8E10246D2D3959DFA6AA10245D8E8A8EA29641696969CAB241202D49082065C6C6CA0C1C516165556979927D61616186B2183179AAAAAAC6C6C2969296DBDBDF243D718A71712031591C3582DFAEAE8E7D86A2A6A6314579866969AA828214285D20316910246592928E1031860410353D5D92F3F3F328499A14399A14203D3539497D754986868E0C2059A28282E3E3E3081024AE9A3D967171454545355992494D61AE8A8E7175797D869ED7A2A26555554D4D51B69296DBD7D7394969928A4D555D65D7A6AA8A7D39142855CAA6AA203982EBCACE5D6569AE9A359E9E9E715959183161B6C2DF5186C22D4169928A55414965BABABE615971AE9E9E0C18394559755979AAEBE3DF31498A5179A22439694159A6313128A6964D9EAABEDFBABE314982514924081849495565A696396969610C287D4535352035719682867171557171694571A64D5D861C3D92D2BE41514141DBCACAEFB6BA49393D24459A315586394561082471C6B649614D55B6AA5D1C2D59BE969A3D49717D7959614949CAB2AE514139244186E3C6CAF3EFEB756935797965867D55595D4561758AFBBEC23D659A1C357161551CBAAA49413D456D798A7D8282617DA2141C35000C2820283D24418A79753DE3DFDB24395D9692695D6986283965B2B2B23559968A8279FBFBEF8692AEEFD74D516D96C6B6559A8E45353541A69E5D82615D967D79454531D2BE4D92864561869E14244D554D456D6555393D555D61613159A6B286867592B29E8A351C316DF7FBFBFFC6C665757D1C397D555D7DCECACA1C3979182D71BEC2CE4539206D611C866561FFFFFF21F904010000FF002C00000000440047000008FF00FF091C48B0A0C18308132A5CC8B0A1C38710233E74674CA2C58B08C5E4B8900F16C68F1651697C152011C8930E977DD3A6F100CA970BC5C9C92166D92431307316540149C2AB1CDE64EA1CFA2FDA87483968CE01878E684E246A7E591A9369DBBE664E5F669254E357264BD3BAE2819715243C0A3FAA90DA45CF519518562894FDA8A451851E3DA8E0C0DBA34D3D25733156A0A32990AFC281FED02115F862333AACE6593A24F550183EB71A5BAC42C7579843785A1D7A52435306249A1F12BB1567452B568134E10864184706478C5333248645C70A3E545A151BDE8A'
$sBinGIFImage &= '0F9F0C59C645D2BD70CE381D192A00C7419DCA0AE851A200669E905B1B1D59A264FFD171A7C29D3869B0544893663BF7834AD2E878A7AE1096FB5892D4D185FCC77B8555E8E0883AAEF0B2CA81AE8812C31F59CCF15F4255E013060241ACE2CA856E7451430DBBA0F6E0418CFC5243183570D0055C4F90D855261F1AC44D586AE0F1C4346AA8F1C41378C818A3832D0E840D1E1C144101214EFC10430C4E60C0880D08E063458F0229C10436D830614A21B75041051F59D47186154C6060857B1FCE51A413419CB0CB1F155470CB1F8EB473C20F3F10D2548F679C70423B31E0C301051B6CC008051CD810449A319C01A529EDB8C00C0708441A24A44D3212840B413003252EE198B2411191861AAA9056B4C303253D9E3204343130C108A8A246FF4A81065604F185212DBA13CB258F04E1043636C03A2A234CFCA0CC1A5FE4F3E03DB598334B1F6EC44008B0C2526003064E9832C4140494100D18DCF522432DDD74534D19A074C1C4061414E1AE0DD88C10831B054860EF0507BC919A0AD1C880CA37D598730509653033EDA0D6128BE6B6537C7081BD074CD258360294708135937821483B32D8F282BA1BD8400123D8101283324B8883CB14164B700104F69C52960A0F5C60732A1008E0413E071C50C60907DBB001B62E4C708F399E784080C33643207156BD9470EF070404208F008094F0801D203342EB093CC8608A397AA4B0440810A4F28A045364E3943153D82B412A5E3CD04002F6007240098604FF31ED06D83861C703105C318B10476CB1C726D5D4A3C0058038958FD46B07014A0A2CE0220001807C00010F3160808D152FC853C20121E4A20A382C60924C300AACDDF650F55CA1B602F5D4D2411FEB94620FE77B2F01C70818FCC043CF3D8B20CCEE8360E2F0BDBDE8D40C2EA9DC1B0D208B00B345289BEBBD770A273001C7143D0302880022E4314C1F1D4002814F1240103D4C9BBC7F2F014B7051C60D09189037F221488420187000F3018200F610C0120AE086580822040FB3D71440F01228340010AF78C5053E20007DF8410AFA08C0037EE73DADF9E0000448E10113688014A4C30709C89A4F2E20002D80EB24D780C11A5A6080541CC00033184201FF18C0800808200421F0DE01A7600F6EA590850C68413A182000089460028F58C31A6E884318E8900706F0C0AA0650800124E00182B84212CD470001B8F1776D34C00306E087474CE0015080C61A74C8459424E20BCEE045387CD0023F04A000050880084C910C35AED08D6E4CA1000C60802D68E11146B0052F44B10632F4112588384521508002657CA100FA2840031409095528220492A42424DD28823DB8800B8F20C328DB0087ACB4860A7480430306708D44DC2014B998C52C1E294B01E4037DA1D0830B88900E72E0E0388A220A12B290811564200EF220A6191251'
$sBinGIFImage &= '8A0ECC2219BF73A32C45100C458002141D580711E0E0CD1554801CA81A0A12DE91FF810CD4E116A318C004A4C1860E744008C110813A2949497B2842151DA0011086D18834446105B7408153908002D69021035018400358400321084118906428431F600045449406D2684414D8B18238A0603943B1863FB2F38524E0A2003358C0223CE10903A4F4014865E812842104894A610FEC18421AFC5108A750A20E3B8506341800542D34C0032260E94A2380D40788E00542D0831ED8C0834E7CA10EE4488237B2428946D022099C40A416B45080049075AC11202B4BDBF182048C420F7048072D0AA18BB9CEC50EC0E0C43576E003BE06E0AF728C4002361BD80878C00309F040256231047570E21E8808CC30E2818C3E9881053E48A45FCBBAD900FF6CF6B6B5D5470386800C7E78642E8860413FFAF00970B821B60CB02D529790800038D7B9B7752E5787C08974FC762E9740C627CEB10534F035B99BBD022E3C10007DDCE0B9CF256201A4A08E4E5C372B60E0871DCC30081E547688B6F5401E30510912546211E7452F03C8A88572E432302A4807170A60063BA0C102654CAE7E69908B2300C11301962E570B5060673C2230C630C1041A90026A5800C22918803E46E10920B08106A5B80111931B00F572D80816480788455C8009CCC0027C2D803C4A01840EB0E1C87990F18C67ACD774580057733184052640E519F821C80CA8C41ECC70641A80A312FA604098990CD47418410B08DEEB0C66A0852B237269C0B258041BCE710433B840C9649E409BAFA002CDC0020A50D0420BA6FCE61BC0810D89D8C10EE4B1641B4FC0022A482D734E01060BC416913758443B1AA0CA05AC79060D6840507D9082147C48056F28B53C183D80141862132088B5AC63FD069941E9D6B84E484000003B'

_GDIPlus_Startup()

;for display
Local Const $hDC = _WinAPI_GetDC($hGUI)

;load bitmap from memory
Local Const $hHBITMAP = _GDIPlus_BitmapCreateFromMemory(Binary($sBinGIFImage), True)
Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC)
Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap)

;empty GDI bitmap
Local Const $hHBITMAP2 = _WinAPI_CreateCompatibleBitmap($hDC, 2 * 68, 71) 
Local Const $hDC_backbuffer2 = _WinAPI_CreateCompatibleDC($hDC_backbuffer)
Local Const $DC_obj2 = _WinAPI_SelectObject($hDC_backbuffer2, $hHBITMAP2)

;copy image normal and inverted to $hHBITMAP2
_WinAPI_BitBlt($hDC_backbuffer2, 0, 0, 68, 71, $hDC_backbuffer, 0, 0, $SRCCOPY)
_WinAPI_BitBlt($hDC_backbuffer2, 68, 0, 68, 71, $hDC_backbuffer, 0, 0, $NOTSRCCOPY)

;display result in GUI
_WinAPI_BitBlt($hDC, 0, 0, 2 * 68, 71, $hDC_backbuffer2, 0, 0, $SRCCOPY)

;convert GDI image to GDI+ image format and save it in PNG format
Local Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBITMAP2)
_GDIPlus_ImageSaveToFile($hBitmap, "c:\Temp\Test.png")

ShellExecute("c:\Temp\Test.png")

;release GDI and GDI+ resources
_WinAPI_SelectObject($hDC_backbuffer, $DC_obj)
_WinAPI_DeleteDC($hDC_backbuffer)

_WinAPI_SelectObject($hDC_backbuffer2, $DC_obj2)
_WinAPI_DeleteDC($hDC_backbuffer2)
_WinAPI_DeleteObject($hHBITMAP2)

_WinAPI_DeleteObject($hHBitmap)
_WinAPI_ReleaseDC($hGUI, $hDC)

_GDIPlus_ImageDispose($hBitmap)

_GDIPlus_Shutdown()

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

While Sleep(1000)

WEnd



func _Exit()
    Exit
EndFunc

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...