tip Posted November 6, 2010 Share Posted November 6, 2010 (edited) Hi to all, I was wondering if there is way to convert a files binary code to an image object. Like _GDIPlus_ImageLoadFromFile() function but reads from binary ... $Up_PNG = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Pics\SearchUp.png") $ZEROGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) $Up_Button = _GDIPlus_GraphicsDrawImageRectRect ($ZEROGraphic, $Up_PNG, 0, 0, 64, 64, 638, 510, 64, 64) I've searched the forum and found Zedna+ProgAndy's UDF (_SetImageBinaryToCtrl()). It is great but that sets the image file to a control. I need an image object to use with _GDIPlus_GraphicsDrawImageRectRect function. (You can see the code above. I tried to tweek the UDF but I couldn't get anywhere. Thanks in advance Regards Tip Edited November 6, 2010 by tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center] Link to comment Share on other sites More sharing options...
Yashied Posted November 6, 2010 Share Posted November 6, 2010 (edited) Edited November 6, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
tip Posted November 6, 2010 Author Share Posted November 6, 2010 (edited) Yashied thanks for the response. I've already looked in your icon udf but I couldn't find a way how I can turn an image binary to an image object. Maybe I'm missing something. And please note that I'm not very good with dllcals... To be more precise I'll try give an example: My Code is like this: $Up_PNG = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Pics\SearchUp.png") $ZEROGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) $Up_Button = _GDIPlus_GraphicsDrawImageRectRect ($ZEROGraphic, $Up_PNG, 0, 0, 64, 64, 638, 510, 64, 64) I want to turn it to something like this:$Up_PNG_Binary = 0x521521041320415406084121216546840641320165456804641241687498465041321021354684890464324013521654654654... $Up_PNG = ***A_Funtion_to_Turn_BinaryCode_to_Image_Object($Up_PNG_Binary)*** $ZEROGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) $Up_Button = _GDIPlus_GraphicsDrawImageRectRect ($ZEROGraphic, $Up_PNG, 0, 0, 64, 64, 638, 510, 64, 64) Thanks again for the quick response Regards Tip Edited November 6, 2010 by tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center] Link to comment Share on other sites More sharing options...
tip Posted November 6, 2010 Author Share Posted November 6, 2010 (edited) Based on what I've seen in the UDF's I wrote this. Func _ImageLoadFromBinary(ByRef $Binary) Local $hData, $pData, $pStream, $pBitmap, $hBitmap Local Const $STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0, $SS_BITMAP = 0xE, $GWL_STYLE = -16 Local $picdata = Binary($Binary) Local $piclength = BinaryLen($picdata) Local $picstruct = DllStructCreate("byte[" & $piclength & "]") DllStructSetData($picstruct,1,$picdata) Local $picmemory = DllStructGetPtr($picstruct) $hData = _MemGlobalAlloc($piclength,2) $pData = _MemGlobalLock($hData) _MemMoveMemory($picmemory,$pData,$piclength) _MemGlobalUnlock($hData) $pStream = DllCall( "ole32.dll","int","CreateStreamOnHGlobal", "int",$hData, "long",1, "Int*",0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipLoadImageFromStream", "ptr", $pStream, "int*", 0) If @error Then Return SetError(@error, @extended, 0) $GDIP_STATUS = $aResult[0] Return $aResult[2] Endfunc It was making sense to me but clearly I dindn't understand the routines very well... It didn't work... Although I thought it could be starting point. Regards Tip Edited November 6, 2010 by tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center] Link to comment Share on other sites More sharing options...
UEZ Posted November 6, 2010 Share Posted November 6, 2010 (edited) This might help you: expandcollapse popup#include <GDIplus.au3> #include <GUIConstantsEx.au3> #Include <Memory.au3> _GDIPlus_Startup() Local $hImage = Load_BMP_From_Mem(Background_PIC()) Local $iX = _GDIPlus_ImageGetWidth($hImage) Local $iY = _GDIPlus_ImageGetHeight($hImage) Local $hWnd = GUICreate("Display image from memory by UEZ 2010", $iX, $iY) GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) _GDIPlus_GraphicsDrawImageRect ($hGraphics, $hImage, 0, 0, $iX, $iY);copy bitmap to GUI GUISetState() GUIRegisterMsg(0x0014, "WM_ERASEBKGND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hWnd) Exit EndSwitch WEnd Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam) _GDIPlus_GraphicsDrawImageRect ($hGraphics, $hImage, 0, 0, $iX, $iY) Return True EndFunc ;==>WM_ERASEBKGND ;====================================================================================== ; 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 $ghGDIPDll 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($ghGDIPDll, "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 Background_PIC() Local $bitmap_data = '0xFFD8FFE000104A46494600010101004800480000FFDB004300191113161310191614161C1B191E253E29252222254C373A2D3E5A505F5E595057566470907A646A886C56577DAA7E889499A1A2A161' $bitmap_data &= '78B0BDAF9CBB909EA19AFFDB0043011B1C1C252125492929499A6757679A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9A9AFF' $bitmap_data &= 'C0001108015C016003012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D0102030004110512' $bitmap_data &= '2131410613516107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435363738393A434445464748494A535455565758595A636465666768696A73747576777879' $bitmap_data &= '7A838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F0100' $bitmap_data &= '030101010101010101010000000000000102030405060708090A0BFFC400B51100020102040403040705040400010277000102031104052131061241510761711322328108144291A1B1C109233352F0' $bitmap_data &= '156272D10A162434E125F11718191A262728292A35363738393A434445464748494A535455565758595A636465666768696A737475767778797A82838485868788898A92939495969798999AA2A3A4A5' $bitmap_data &= 'A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00EA68A28A004A28A2800A28A2800A5A4A' $bitmap_data &= '5A0028A28A004A28A2800A28240EA69BBFD066801D41351EE27BFE5556FAF61B180CB3B703A0EEC7B01401667B986DE26965915235EAC7A5625C78AEDD09104124A47F788407F99AE7B53D4E7D465DD2' $bitmap_data &= '9DB1A9F9630785FF001354A803725F14DFB83E5A4318F50A49AAAFAFEA8DD6E88FF763518FD2B368A00BA757D44FFCBECDF9D31B53BF63CDEDC7E0E4555A075A00B6BA95F29E2F2E3FEFE1353C7AE6A7' $bitmap_data &= '19C2DDB30FF69437F4ACEA2803723F146A083E7481FEA841FE75761F16A9C09ECD87A98DF3FA1C572FC7B51C1A00EE6D35FB0BB2144A6273D1651B73F8F4FD6B4B7003920579A62B474DD66EEC18287F' $bitmap_data &= '361EF1BFF43401DDD15474FBF86FE1F36DDC823EF23755356BCDC1C30FCA8024A2915837439A5A0028A28A005A28A2800A4A5A4A0028A28A0028A28A005A28A2800A28A280128A28A0028A28A0029692' $bitmap_data &= '96800A2929ACDD875A0071200E698589E9C52753CD18A004C7AF34BDA8FD4D183DFF004A00648E11493FCEB94D512E754BD6F223792388EC1B06467B9CD758D1238C32823DEA1FB05991836B0919CE0A' $bitmap_data &= 'E6803935F0EEA2DFF2EEA31EB22FF8D35F41D453ADA93D7EEB03FD6BAB3A5D8B74B645FF00772BFCA9A74E8F9F26E6EA127AEC9B3FCF3401C54D657101C4B04A9F55355F83DFF5AEF0C1A8A488D1DEAC' $bitmap_data &= '88A0FEEE48F696FA919FE5542E4DC04C5DE8D14E0B75800231FCF3401C9E3EB4015B922685712948DE7B66E9B88F941F7CD6348BE5BB28656C7F129C834806D1467D28CD300E28E0D3A18659DF6428D2' $bitmap_data &= '31E81466B52DFC397F2E0C8A9003FDF6E7F21401918EB4B9E3AD7556DE17B440A6E659256EA557E51FE35A7058DA5B0FDC5B4687D76E4FE668038ED3E5BBB5B84B8B68A4623A8542430F4E95DBC122DD' $bitmap_data &= '40B22065DC39561823EB4E2EDEA69849EB9A000A9539FE54E595875E6981A918D005A4915FA1E7D29D54B383FD6A549F1C3F23D6802CD1480E46472296800A4A5A4A0028A28A0028A28A005A28A2800A' $bitmap_data &= '28A280128A28A0028A28A0028E9413819351925B9ED400A589E9D29296933D81E7F41400BD3AD2633D7F2A31F9D2D001DA92968C134009453B6FA9A5C0A00652F3EF4EA280198F6A4E8734FA69EB4015' $bitmap_data &= '6EECADAED4ADCC0AD9EA7186FCEB9DD43C392C21A4B3732A01928DF787F8D755D3A5318E07F9E2901C3D969B757EE5204FBBC3337017EBFE15D1D97872CE001AE337127BF0A3E83BD6BC0010C400096C' $bitmap_data &= '9C0EA6949A602468912EC891635FEEAA8028CD19A4CD002E69B45266800348682690D001466933499A0043D699BB1F5F4A71A8DA80268E5287E53F81AB71CAB20E3AFA5660247B9A9164C1C838228034' $bitmap_data &= 'A8A861B80FF2B70DFCEA6A0028A28A0028A28A005A28A2800A28A280128A28A00290900734A4E064D46492727F0A0009C9E68A290B7200EA68017D875EFED4A38A4030296800A0734019A7018A004005' $bitmap_data &= '2D2D2500145149400B4945140013519A731A650014C90E14D3B3514BF74F7A0096D8E54FD694D36D0E51B9CF3413400519A4CD266801690D266933400B9A69A0D25002D349A0D21A0009A6B52D34D003' $bitmap_data &= '0D3738A7B546C2901223E78EF572DEE338473F43594CE55B1F954B1CCADD68036851556DA7FE073F4356A98051451400B451450025145140051453246C0C7734008CD93EC2A392548C12C6B3B53D5A1B' $bitmap_data &= '31B3EF49FDD1D6B98BDD42E2F09DEF84FEE2F02803A4BBD76DA2C8594337A20DD8AB9A64C6EA13704150C70A1860815CB6856AB7178C6540F1428CECBD89ED9AEAF4C4D9A6DB0F540C7F1E6802D5039A' $bitmap_data &= '29C06280140C51451400514525001451484E2800CD2134D249A4CD0004D2134526680026A298FCA79C53F3514C7E5340135A1FDD367D683D6996847932633D7BD29340066933452668016928CD250019' $bitmap_data &= 'A4CD04D26680026909A334D2680026909A0D3734800D34D2E6909A0086E14B44C17EF8195FC2B2A1D4A39387055BB8F4AD763DC76AE5F518FCABE9D40C0DD91F43CD0074305D74C36E5FD7F0ADAB2B95' $bitmap_data &= '9D319F997D6B82B7B97881C1CE3A035B7A7DFF009843C6C43AF634C475945456F309E1590719EA3D0D4B40C28A28A0028A28A004AC6D7B5316716C8F99DFF415A97532C10B3B1E00AE0AF6E5AEAE5E67' $bitmap_data &= 'E72703DA9010BBB3B16624B1E49A6FB504D14C0DDD1008B48D4AE09DA4AEC0C3E9DABA5B65D96F120FE1451F4E2B06C832F852520A02DB8E5BA01915D12741F4140878E296928A061451450019A2929A' $bitmap_data &= 'CD8A0052D8A613413494001A292933400A4D349A290D00213504EDF29A748E14735427B9C920520346CDB30C9FEFFF004A79AA56170A44B1EE059581C679E9570734C029294D21340099A4CD04D25000' $bitmap_data &= '4D26683484D0019A426909A69348009A6934134DCD002E6933484D26680063581ADA62ED5FB3A0FD38ADD26B1F5D19F25BEA28032475FD2A4B694C1306EDD0D4541E4FE14C0ECF46BEC3181CFCAE728C' $bitmap_data &= '7D6B72B86D3A6DF1019C3271FE15D7E9F73F6980163F3AF0DFE3408B545145030A28A64AC1509F419A00E7FC5179B631021E5BAD72E6AE6AB706E6FA47CE40F94552A402D349A5349D2981D4C40A785B' $bitmap_data &= '0BB49F2F71CF41CD6EC4D98D0E7AA839FC2B96B7B9497C377313E4B4202E07A6783F4AE8AC641258DBB7AC4BFCA8116B70A5A652838A063A8A2909A00466C5333413CD25001499A33499A005CD2519A6' $bitmap_data &= '3B851C9A0071200AAB7174B1E7904D55BBBE0AA483C0EF59E77CEA6792516F6C33995FF88FA28EE695C092E2F4BB84505D9B85451924D56BC5FB3A117739597A8822C17FF811E82ABCDA90855A2D3A33' $bitmap_data &= '02918695B995C7B9FE1FC2B349CD005A86F64864F3136E4F5DDCE6B5ED35A121559015909C63A2D73B4B9A6076E97432AAC4063C6323FCF6A977822B8DB5BD92D81002B29209C8E98F4ADCB4BF591771' $bitmap_data &= '753C0620751CE31401AD9A4CD4492065073D69D9A40389A6934134D2680149A693484D21340013484D14C2680149A4CD25266800CD65EB7FEA61FF007CFF002AD326B2B5C384817D4B1FE5480C8A0D14' $bitmap_data &= '7639AA027B297CAB85CF46F94D74FA5DC7952A9FE13C115C88EA2B7EC65CAA93F43408EC0515574F94CB6E013F32F06AD50303D2B375BB9F22CA420F27815A24E0126B97F144E7747083D064D26073C4' $bitmap_data &= 'D3694D211C50021A4CD21A298134170F0A4A8A7E49576B0AEB3C3B7225D2D10FDE898A91E80F23F9D71C0648007278E2BADD0348B8B4065B8936190730819FA13E86811B218519A6B5BB0FBAC3F1A8CA' $bitmap_data &= 'CA9D54E3DB9A064E1A94B66AAF9D86C1EA3B5384C0D004A69A4D37CC1EB4D2E2801F9A3351EF1EB55E7B908081D690134B3AC6BC91593777C4B8450CCCFC2AA8C926A296792E6468A1DA580CB3B1C246' $bitmap_data &= '3D58D519B505B60D1D83B348DC4976C30CC3D17FBA3F5340135C3C564CC6EB6CF720E45B86F9233FED91D4FB0ACBBBBB9EF24DF3C85881851D028F403B5419A298051451400514514005490CD2432078' $bitmap_data &= 'DB0C3DB351D1401B363A86E28B2300C0818C76AD68AE15C641AE47A55DB6BF78F89373003822803A6DD49BAA9C574AE3860DEEBEF536EA404D486981A82F8A007134D269A589E9460E32680173494D32' $bitmap_data &= '46A46581CF4C734D12B3FF00AB898F3DE801E47358BADCA1AE5631FF002CD79FA9AD9D9707925107A561EA163342CD2B9F3158E4B8EC7DC50053C700D21E45283918A3BD30183AD6AD84986DA7BD65E3' $bitmap_data &= '9AB70BF96EADE87F4A04759A54BB650A4F0E31F8D6C0AE6AD64DA432F51C8AE91486504743C8A006CA7803D6B87D726F375190E720715DA4EDCB63F856B80BC7DF732B7AB5219075A1A81DE90D301297' $bitmap_data &= 'FA5256EF86F4C1712FDAE750618CE1148FBEDFE02802FF0087B4816EAB7972BFBE6198D0FF0000F53EFF00CAB709A4272793CD1400BB8FAD2F98477A6526680242C8E0875073D6A26B7858E412BEC0F1' $bitmap_data &= '4669A4D0044D6B328F94AC9CFF000F155A46647D8D956F46E0D5DDE45299372E1802BEFCD20335E560A7B71D735917776245DC1D92107EF8EAC7D17FC6AE6B76C00F32157DAC312053C01F8D73B24B24' $bitmap_data &= '857CC6276A851EC3D2840493DCB489E527C90839080F7F53EA6A0CD2514C028A28A0028A28A0028A28A0028A28A0028A28A009A199E13F21E3392A2B66CAED675C67E6CF4C5608EB562CB719D0062371' $bitmap_data &= '00E0E0F5A00E84B0519770A3DE9AB32BB01123CBEE0607E75716D2DA01911EE3EB21DC69249CF41C0F6E29015C4772E08212204F07A9A3ECE9BB3248CC7183CF14A589EB462801CAB1A0C24629779E94' $bitmap_data &= 'D145002E49A6E3D4641EA0F7A5A290187A9597D9D84B08FDD31E47F74FA7D2A89E79AEA2445746561956186AE76EED9AD6731B72BFC27D453021C6483528E7BD442A45A00DAD3A4DF146D9E7A1AE9EC1' $bitmap_data &= 'F75AA0FEEFCB5C7E96F82E9E8435751A53F0E99EC1BFA1A621D74F88266FF64D704E7249F539AEFA48BCE8DE3E9B948AE065431C8D1B70C84823D297518DA4A28C64F14C0B16166F7D771DBA7058FCC7' $bitmap_data &= 'D07735DDC512410AC310C471A8551E9FFEBACCF0ED87D92CBCE7044B380707AAAF61FD6B5280173499A4A280149A6D1494001A69A53486801B4529A69A00A3A9A892DD9480723BD720C3048F438AEDAE' $bitmap_data &= '40DB9AE46FA3F2EE9C6EDD9E7E99A5D40AD45145300A28A2800A28A2800A28A2800A28A2800A28A2801455DD2D37DE4791900F41D6A956BE891E58C98E0753401B5339CE2A0EF4AC7269290052D14500' $bitmap_data &= '28A2814B400514514000AA9A85A0B980851FBC4F993DFDAAE521F51D7B5007298F51834F43C55DD5AD7CA9C4A8BF24BC9F635453D2802EE9ED8B9C7AAD74DA5BE2751FDE523FAD72B6876DD467EA2BA3' $bitmap_data &= 'B06DB24593F30607F034C46BA706B9DF12E944B1BDB75CE7FD6281FAD7424E0FE74EE19707A1A433CE2B4345B1FB6DEA2B7FAB1F331F615B1A9E8311633428C0756541FD2AC6836E21B79A5DB8323EC0' $bitmap_data &= '08C7CABFFD7A00D42727A63D3E9494525300A28A4A0033499A0D14001A6D29A6D001484D04D349A4032519435CCEB31E25570A391F330CF35D33F4AC6D6220D6EC4E46DF9B8E9401CF9A28228A601451' $bitmap_data &= '4500145145001451450014514500145145002A825801D4FAD745A747E5DB673C91587671EF980C1247207AD74A06C8C28E31498094528A290052D252D30014EC52014B4005145140051DA9690D004375' $bitmap_data &= '00B9B778BB9E87DFB573A8B899011804E315D45635FC18D464551F7B0EBC7AFF00FAA80086054B8DED8DABFCEB5B4F04CBBDBBE3354E0809F99B9FAD6ADAA6D03EB401A2DD7F1340349270C7EB40A604' $bitmap_data &= '81B14D3CF3499A40722800A6D29A4A00293345250014526683400669A4D0690D2010D21A09A69340086AA5D2074208E0F635689A864E45007253218E4652307351D5FD5A211CC1C646EED54284014514' $bitmap_data &= '5300A28A2800A28A2800A28A2800A28A5419603D7F1A00D5D2203BB7118EFD3922B58F26AB584423806076C67D6ACD20168A05140052D145000296814B40094B4B450025069692800A8A640D306E33B4' $bitmap_data &= '7352F6A6B60C9F402801635C2D5A88722A2030A054D08CB2FD45005D9C61CFE7518353CE3907F0AAE2980ECD229EBF5A334D0793400E269282692800A4A2933400521345252002690D1484F3400869A6' $bitmap_data &= '94D30D0006A37A79A635203335588BDBB1032579AC1652A706BAB9577020D61DD5B796F870DB3F85BA91EDF4A680CFA2A53037F0B2B7D0D37C993FB86980CA29DE549FDC6A3CA7FEE3500368A779727F' $bitmap_data &= '71BF2A3CA7FEE1A006D14FF264FEE9A5F25BB951F534011D5BB188BCC0601C0CF350848D7AB827D056B6956E42798DD58E47B52034546140A5C52E3BD1400514B4500252D14B40094EA414B400514B45' $bitmap_data &= '002514B450020148012E73DCF14E240524D118C01ED40121FBD562D5732A8FC6ABA8E6AED92E5C9F414016A55CA1F51551B8E6AF5549170C57F114C06669A4E0D2D358F1C50038D25267201A33480292' $bitmap_data &= '8A4A002928A4340052134521A00434DA5A4A00434D6A71A6E371A4033031963851C9345B44ACAD348832FF002A83D97FC69251E6B88547CA396352B37181D2802ACDA65A4849F2C29FF64E2AAB68F076' $bitmap_data &= '661F8D68939A4A00CD3A447FDF7FCE90E9098E5DBF3E2B4FF1A314019474A4FEFBFE747F64C7FDE6FCEB57146D140197FD9317707FEFAA51A5C23F801FA9AD4DA28DA28033858423AC4B562D87927CA3' $bitmap_data &= '8F2CFDC6F7F4AB054531D01183D0D0038D14B192EA77637AF5F71EB4628012968C52814C04A2969714008052D18A5A004A29714B834009453B6D18A008DB3C0E307AD3D4714D037B939C8A9280154568' $bitmap_data &= 'D9AE22CFA9AA2832462B51142205F4A007543703A37E15353645DC8453029919A69538A7D21A00893BAFA73450DF2B6E14E201E477A40369297068C1A0069A434EC1A4C5003690D3F148680194869D8C' $bitmap_data &= 'D3483400D393D2891844B81F7DB81ED4F00202CC781EB512E6472E4E476C8C520045D8806724F5269314F3C9A4C5301B8A314EA4C52013146297145300A28A2800A2968C500252114EC518A40447E461' $bitmap_data &= '205CB0E2A665C8DC07069A47A8A21C29F289273C827F95300C52E38A7151462801B814EC514B40098A2968A0028A5A2801291B85CF7A7E29BD587A0A00455C0A70A5A5028027B44DD2E4F45E6B405416' $bitmap_data &= '91ED8B27AB7353D300A28A2802AC8BB5C8A8CD599D72B91D455734011B0E2A1699205CCAC1533F78F6A9DC71587E219088121504976E83BD2036CF63C63D41C83495C8DB6A37D61850C760E0238CAD6C' $bitmap_data &= 'DAEBF6D2AA8B856898F52395A606A521A22749937C2EB227F790E7F3A5348069A4A53494001A4C6697AD24ADB138FBCDC0E3A500452B6F608ADC0FBC29C13803B511AE17279CD3E801BB4526DA7D1401' $bitmap_data &= '1628C5494628023A29E4518A008F14629F8A5C5003314014FC52D003768A368A751400D22A3914FF0009C1EC6A6C52114008AE244DC33C75A314C04C7203C907822A62280194B4B8A4A0028A5C64FF00' $bitmap_data &= '414C9E586D941B8952207A6EEA7E82801F8A503A9E807527A0FAFA5654DAF40A316F1348DD32FC0ACAB9BFBABE0048C4A7FCF34181401D247730CE596070F8382454A38AE7B436315C946C2EEAE8B140' $bitmap_data &= '0952C51EF70BEBD698055DB48F0A5C8E4F02802C8000E28A28A6014514500155245DAD8EDDAADD3254DEBC751D28029B74AC7D51034EAC41250607B56D30E2B2B514F9F3480CC619041C63DEAB49671B' $bitmap_data &= 'F20153ED5708A6914C0CF58AE2DDF7C12B291D0A9C1AB916B7A8C231304987AC8B93F98E6948A6114017E1F115B380278248C9EA508603F3E6AE47A9E9F2FDDBB45FFAE8A56B05A356FBCA0FD4540D6C' $bitmap_data &= '87A023E86803AB37768ABB8DDDBE3DA414C8CF9C7CCDDB958654E3B572124463E7823D7D2BA9D1A713E9917768F31B0CFA74A405C3462968A004A4A7525002514B450025252E28A004A2971462800A4A' $bitmap_data &= '5A2800A28A5A004A4A5A2801ACB915564D4ADAD6430DC39565E985CD5C38032C70A3924F615C85DCE6EEF65957F8DB8FA76A00DF7D72C17EEB4B27B2A63F99AA72F884F482D80F432367F4AC91128FBD' $bitmap_data &= 'CD386074005005A9B56BF9F8127963182231B41AA62224E59B9F5EB9A7E4934E5E94008B12E7919FAD48050053C0A009EC062E91BA60E338AE857A561D821F3D48CFD456F01C5301F1465DC28FC6B400' $bitmap_data &= '00003A0A8ADE3D8BB8FDE6FD2A6A0028A28A0028A28A0028A28A00AF3260E4743FA5676A11E5738AD8650C083D0D67DD2B2828CA194F43DE8030DD6A32B57258F048A81969015D854647356196A365A6' $bitmap_data &= '0458A691C53C8A4229010BAE4608CE6A5D22EFEC379B2427ECF37CA4FA1EC6908CD4334618106981D6B0DA70692B3743BE33C5F6498E658972AC7F897FC4569E29005262968A004C514B450025262969' $bitmap_data &= '6801B8A2968A004A314B45002514B45002514B51CF3476F0BCD29C220C9F7A00CED76F3C8B7FB3C67F7930C37A85FF00EBD6122EC5ED93E94F9656B99DEE65FBEE7200EDE95196C9A0009A2929545003' $bitmap_data &= '8548A29AA2A55F619F7A005029E8B9342AE6ACC517E74C0B7A6C5FBC271D2B6EDE2DCD93F74553D3E07C15518CF2CC7B0F4AD7550A000381400B4514500145145002D14514009451450014D9103AE0D3' $bitmap_data &= 'A8A00CABAB6CE481CF7AA0F1E3208AE8648C38F7ACFB9B6CE481CD2032192A265ABB24646460D40C9401519698455965A89969810E29AC38A948A691480AF978A5496162B221DC86BA6B1BB8EFAD9668' $bitmap_data &= 'F83D1D7FBADDFF000AE7D973F8D259DD49617226505A338F313FBC3FC45303A8A292391268D6589B7C6C32A47A7F8D3B14804A4A751400DA314B45002514B45002514B45002514B8A314009DF18AE775' $bitmap_data &= '6BD17570628DB3045DC7476ABDAC5FF9486DA023CD71F3907EE0F4FAD603B050157A0A00491B2714CA4A5A00515228A6AAF4A9D138A600ABCD4E8849A58E227B55B8A1F6A006471D69D859991F2471F4' $bitmap_data &= 'A5B3B3691BA62B6A28D6240AA3FF00AF400B1A2C6A15474A7514500145145002D145140051451400945145001451450014D740C39A752D0067DC5B67B7E3542584A93906B78804608AAF35B06E833401' $bitmap_data &= '80E950B256B4F6C57240C8F4AA4F1E33C52028B2D308F6AB4E9CD42CB40109151BA835330A610698126977E6C2529264DB391B80E761FEF0AE8C608054865619520F51EA2B94931C02325BA01CD6A68C' $bitmap_data &= 'B756F1B073FB96E911E40FC6901AF8A314D1321EA0A9A5DE87A30A0028A5CAFA8A38F5A004A28E3D45191DC8A0028A42CA3B8A699147A9A007E2B3F52D405B030C0434E4738E420F53EA7DAA6B969A48' $bitmap_data &= '5922631923008EB5CECCAD071306CFF78F434010C8D8CE5896639249E49A80D3DDB3CE6A3EBC0A0050326A454269F1444F6AB71407D29811450D5A8E1CF6A9E283DB35761B53C641FA0A00AD1404F41F' $bitmap_data &= 'A5695A596F39EC3B9AB56F641797181FDDABAA00000000F41400D8E358D70A31FD69D4514005145140051451400B4514500145145002514514005145140052D252D001494B450031D158723F1AA93D98' $bitmap_data &= '61903F1ABB450060CF6AC9CE38AA8F19F4AE99E256F63EB5525B6507E7418F51401CFB478EBC7D6912DA590E11767FB4C39FC16B6C5AC4A73819F7A9156341C103E9480CEB3D35223B8825C9F989E49A' $bitmap_data &= 'BEB18518029FB9474A42DF4A00428290C4A7A8A524D19A006F94BE94794B4B45002794BE9486343D69D450037628ED4BB56968A004205432C09229565041EB53519A00C2BAD0D598BC0DB7FD9ED5485A' $bitmap_data &= 'F94712C6C873D71B97F3ED5D4E47714D748D87CE463DC50062C16D9008C37B835761B43C647156E2B6877E6284313DD54568456C1797C67D05302A5BD9E718181EA6AFC50AC7D064FAD483A5140052D1' $bitmap_data &= '45001494B494005145140051451400B4514500145145002514514005145140052D252D001451450025145140051DA8A2802096DA393D54FB7F85577B5957EE10FF00A1ABF45006531643875653EE2943' $bitmap_data &= '83D0D6A544D6D049CB44B9F51C50051068CD4B359C680947907FC0B3FCEB3E491E3FE2DDF51480B79A3354C4EFED4E12B1F4A00B39A3350AB16EA6A4099FE36FD2801DBA90B0F5A516E0FF00CB47FD3F' $bitmap_data &= 'C2A54B146FBD2CBF98FF000A0080BD30CAA0E3233E9DEAFA69F6E3EF296FF7989A9E3863887EEE355FA0A00CC8E29E5FBB1B01FDE6E2ACC76001CCCFBFFD91C0ABB450022A855C28007A014B4514C028' $bitmap_data &= 'A28A005A28A2800A4A5A4A0028A28A0028A28A005A28A2803FFFD9' Return Binary($bitmap_data) EndFunc Br, UEZ Edited June 12, 2011 by UEZ DinFuv and Parsix 1 1 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 More sharing options...
tip Posted November 6, 2010 Author Share Posted November 6, 2010 I think I figured out how to do it. Actually wolf9228 is the author of the func I just trimmed it a bit to make it only return image object. expandcollapse popupFunc _ImageLoadFromBinary(ByRef $BinaryData, $GDIPlus_ShutDown = True) Local $tSize = StringLen($BinaryData) / 2 Local $DATA = DllStructCreate("byte[" & $tSize & "]") DllStructSetData($DATA,1,$BinaryData) Local $uFlags = 0x0002 , $dwBytes = DllStructGetSize($DATA) Local $hMemory = DllCall("Kernel32.dll","HANDLE","GlobalAlloc","long",$uFlags,"long",$dwBytes) if @error Then Return -1 Else $hMemory = $hMemory[0] if $hMemory = 0 Then Return -1 EndIf Local $hLock = DllCall("Kernel32.dll","ptr","GlobalLock","HANDLE",$hMemory) if @error Then Return -2 Else $hLock = $hLock[0] if $hLock = 0 Then Return -2 EndIf Local $Destination = $hLock , $Source = DllStructGetPtr($DATA), $Length = $dwBytes DllCall("Kernel32.dll","none","RtlMoveMemory","ptr",$Destination,"ptr",$Source,"long",$Length) if @error Then Return -3 EndIf Local $fDeleteOnRelease = True , $Status , $ppstm , $Error Local $Error = DllCall("Ole32.dll","int","CreateStreamOnHGlobal","ptr",$hLock ,"int",$fDeleteOnRelease,"ptr*",0) if @error Then Return -4 Else if Not ($Error[0] = 0) Then Return -4 $ppstm = $Error[3] EndIf Local $gdiplusOpen = DllOpen("gdiplus.dll") Local $ImageType = 0 , $ImageWidth = 0 ,$ImageHeight = 0 , $struct_GdiplusStartupInput , $Input , $LPInput , $VOID _ , $LPVOID_token , $Status , $HBITMAP , $HENHMETAFILE , $GdiPlus_Dll_Hwnd , $GdiPlus_Token $struct_GdiplusStartupInput = _ "int GdiplusVersion;" & _ "int DebugEventCallback;" & _ "int SuppressBackgroundThread;" & _ "int SuppressExternalCodecs;" $Input = DllStructCreate($struct_GdiplusStartupInput) DllStructSetData($Input,"GdiplusVersion",1) DllStructSetData($Input,"DebugEventCallback",0) DllStructSetData($Input,"SuppressBackgroundThread",0) DllStructSetData($Input,"SuppressExternalCodecs",0) $LPInput = DllStructGetPtr($Input) $VOID = DllStructCreate("int") $LPVOID_token = DllStructGetPtr($VOID) $Status = DllCall($gdiplusOpen,"int","GdiplusStartup","ptr",$LPVOID_token,"ptr",$LPInput,"ptr",0) if @error Then Return -5 Else if Not ($Status[0] = 0) Then Return -5 $LPVOID_token = $Status[1] EndIf Local $stream = $ppstm , $image = 0 $Status = DllCall($gdiplusOpen,"int","GdipLoadImageFromStream","ptr",$stream,"int*",$image) if @error Then Return -6 Else if Not ($Status[0] = 0) Then Return -6 $image = $Status[2] EndIf if $GDIPlus_ShutDown = True Then DllCall($gdiplusOpen,"int","GdiplusShutdown","ptr",$LPVOID_token) DllClose($gdiplusOpen) $GdiPlus_Dll_Hwnd = 0 $GdiPlus_Token = 0 Else $GdiPlus_Dll_Hwnd = $gdiplusOpen $GdiPlus_Token = $LPVOID_token EndIf Return $image EndFunc Thanks everybody for their kind help. Regards Tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center] Link to comment Share on other sites More sharing options...
muhmuuh Posted November 9, 2010 Share Posted November 9, 2010 hi, everyone! just wanted to ask how do you convert an image to binary data? I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
trancexx Posted November 9, 2010 Share Posted November 9, 2010 Probably some DOS command. Help file; FileOpen(), FileRead(), Binary(), etc... ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted November 9, 2010 Share Posted November 9, 2010 Take a look here: Br, UEZ 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 More sharing options...
Leo1906 Posted July 8, 2016 Share Posted July 8, 2016 On 6.11.2010 at 7:42 PM, tip said: I think I figured out how to do it. Actually wolf9228 is the author of the func I just trimmed it a bit to make it only return image object. expandcollapse popupFunc _ImageLoadFromBinary(ByRef $BinaryData, $GDIPlus_ShutDown = True) Local $tSize = StringLen($BinaryData) / 2 Local $DATA = DllStructCreate("byte[" & $tSize & "]") DllStructSetData($DATA,1,$BinaryData) Local $uFlags = 0x0002 , $dwBytes = DllStructGetSize($DATA) Local $hMemory = DllCall("Kernel32.dll","HANDLE","GlobalAlloc","long",$uFlags,"long",$dwBytes) if @error Then Return -1 Else $hMemory = $hMemory[0] if $hMemory = 0 Then Return -1 EndIf Local $hLock = DllCall("Kernel32.dll","ptr","GlobalLock","HANDLE",$hMemory) if @error Then Return -2 Else $hLock = $hLock[0] if $hLock = 0 Then Return -2 EndIf Local $Destination = $hLock , $Source = DllStructGetPtr($DATA), $Length = $dwBytes DllCall("Kernel32.dll","none","RtlMoveMemory","ptr",$Destination,"ptr",$Source,"long",$Length) if @error Then Return -3 EndIf Local $fDeleteOnRelease = True , $Status , $ppstm , $Error Local $Error = DllCall("Ole32.dll","int","CreateStreamOnHGlobal","ptr",$hLock ,"int",$fDeleteOnRelease,"ptr*",0) if @error Then Return -4 Else if Not ($Error[0] = 0) Then Return -4 $ppstm = $Error[3] EndIf Local $gdiplusOpen = DllOpen("gdiplus.dll") Local $ImageType = 0 , $ImageWidth = 0 ,$ImageHeight = 0 , $struct_GdiplusStartupInput , $Input , $LPInput , $VOID _ , $LPVOID_token , $Status , $HBITMAP , $HENHMETAFILE , $GdiPlus_Dll_Hwnd , $GdiPlus_Token $struct_GdiplusStartupInput = _ "int GdiplusVersion;" & _ "int DebugEventCallback;" & _ "int SuppressBackgroundThread;" & _ "int SuppressExternalCodecs;" $Input = DllStructCreate($struct_GdiplusStartupInput) DllStructSetData($Input,"GdiplusVersion",1) DllStructSetData($Input,"DebugEventCallback",0) DllStructSetData($Input,"SuppressBackgroundThread",0) DllStructSetData($Input,"SuppressExternalCodecs",0) $LPInput = DllStructGetPtr($Input) $VOID = DllStructCreate("int") $LPVOID_token = DllStructGetPtr($VOID) $Status = DllCall($gdiplusOpen,"int","GdiplusStartup","ptr",$LPVOID_token,"ptr",$LPInput,"ptr",0) if @error Then Return -5 Else if Not ($Status[0] = 0) Then Return -5 $LPVOID_token = $Status[1] EndIf Local $stream = $ppstm , $image = 0 $Status = DllCall($gdiplusOpen,"int","GdipLoadImageFromStream","ptr",$stream,"int*",$image) if @error Then Return -6 Else if Not ($Status[0] = 0) Then Return -6 $image = $Status[2] EndIf if $GDIPlus_ShutDown = True Then DllCall($gdiplusOpen,"int","GdiplusShutdown","ptr",$LPVOID_token) DllClose($gdiplusOpen) $GdiPlus_Dll_Hwnd = 0 $GdiPlus_Token = 0 Else $GdiPlus_Dll_Hwnd = $gdiplusOpen $GdiPlus_Token = $LPVOID_token EndIf Return $image EndFunc Thanks everybody for their kind help. Regards Tip I'm sorry I need to dig this old Thread out aggain, but it seems that your function runs really fine .. until you want to run it on a 64-Bit system (compiled as 64-Bit). My skills are aktually far to low to adjust the Funtion myself .. Does anybody know how to transform it for x64 use? :/ Link to comment Share on other sites More sharing options...
AutoBert Posted July 8, 2016 Share Posted July 8, 2016 Have a look in the first example works for you. Leo1906 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now