nuki Posted May 28, 2009 Share Posted May 28, 2009 (edited) hey guys i got a problem editing a picture. At first i load the picture to my exe file with the resource hacker, thats no problem, but then i want to load the picture to memory, edit it, for example with some drawings and display it on a control then. Thats what i got so far: expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=gdiptest2.exe #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Run_After="ResHacker.exe" -add %out%, %out%, gditest.bmp, bitmap, test2, 0 #AutoIt3Wrapper_Run_After="upx.exe" --best "%out%" #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #Include <WinAPI.au3> #Include <GDIPlus.au3> #include <Constants.au3> $guiMain = GUICreate("test",500,500) $guiPic = GUICtrlCreatePic("",0,0) GUISetState() $hInstance = _WinAPI_GetModuleHandle("") $hBitmap = _WinAPI_LoadImage($hInstance, "test2", $IMAGE_BITMAP, 0, 0, 0) ;// here i should write the picture edit part but i dont know how to "transfer" that bitmap handle to something else to use it with _GDIPlus_Graphics functions. _SetBitmapToCtrl($guiPic, $hBitmap) While 1 Sleep(10) WEnd Func _SetBitmapToCtrl($CtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 Local $hWnd = GUICtrlGetHandle($CtrlId) If $hWnd = 0 Then Return SetError(1, 0, 0) ; set SS_BITMAP style to control Local $oldStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) If @error Then Return SetError(2, 0, 0) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOR($oldStyle, $SS_BITMAP)) If @error Then Return SetError(3, 0, 0) Local $oldBmp = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) If @error Then Return SetError(4, 0, 0) If $oldBmp <> 0 Then _WinAPI_DeleteObject($oldBmp) Return 1 EndFunc read the commented line with my problem too please just loading it from the resource and display it is working with this example, i only got the problem with editing the picture thanks for any help Edited May 28, 2009 by nuki Link to comment Share on other sites More sharing options...
JackDinn Posted May 28, 2009 Share Posted May 28, 2009 (edited) what about $hbitmap = _GDIPlus_BitmapCreateFromFile() $backbuffer = _GDIPlus_ImageGetGraphicsContext($hbitmap) then you can draw all you like _GDIPlus_GraphicsDrawImageRect($backbuffer, etc.... then put down the result _GDIPlus_GraphicsDrawImageRect($hForm1, $hbitmap maybe is what you want. Edited May 28, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
nuki Posted May 28, 2009 Author Share Posted May 28, 2009 imagegetgraphicscontext doesnt work somehow, and bitmapcreatefromfile isnt possible cuz the resources of an exe file cant be read with that, and i dont wanna create a temporary bitmap somewhere i tried that already :/ Link to comment Share on other sites More sharing options...
JackDinn Posted May 28, 2009 Share Posted May 28, 2009 hmm, well good question then , soz Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
oMBRa Posted May 28, 2009 Share Posted May 28, 2009 try _GDIPlus_BitmapCreateFromHBITMAP and then _GDIPlus_ImageGetGraphicsContext Link to comment Share on other sites More sharing options...
nuki Posted May 28, 2009 Author Share Posted May 28, 2009 try _GDIPlus_BitmapCreateFromHBITMAP and then _GDIPlus_ImageGetGraphicsContextnot working already tried and just tried again $hInstance = _WinAPI_GetModuleHandle("") $hBitmap = _WinAPI_LoadImage($hInstance, "test2", $IMAGE_BITMAP, 0, 0, 0) $hBitmap2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hBitmap3 = _GDIPlus_ImageGetGraphicsContext($hBitmap2) MsgBox(0,"",_GDIPlus_ImageGetType($hBitmap3) & @CRLF & @error) ImageGetType returns -1 ($GDIP_IMAGETYPE_UNKNOWN) and @error is set to 4 (Invalid image handle) Link to comment Share on other sites More sharing options...
JackDinn Posted May 28, 2009 Share Posted May 28, 2009 (edited) hmm, are you sure that _WinAPI_LoadImage($hInstance, "test2", $IMAGE_BITMAP, 0, 0, 0) does not return a hImage not hBitmap? have you tried $hInstance = _WinAPI_GetModuleHandle("") $hImage = _WinAPI_LoadImage($hInstance, "test2", $IMAGE_BITMAP, 0, 0, 0) $hGc=_GDIPlus_ImageGetGraphicsContext ($hImage) just stabbing in the dark a bit here. Edited May 28, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
nuki Posted May 28, 2009 Author Share Posted May 28, 2009 (edited) i tried all combinations i could imagine with ImageGetGraphicsContext and BitmapCreateFromHBITMAP... just found _WinAPI_LoadBitmap, but it seems to be exactly the same... same results at all ImageGetGraphicsContext always returns -1 and BitmapCreate always returns 0 but _WinAPI_LoadImage / LoadBitmap always returns some hex adress like 0xE60525E6... its always different when i restart the script Edited May 28, 2009 by nuki Link to comment Share on other sites More sharing options...
oMBRa Posted May 28, 2009 Share Posted May 28, 2009 have u added ''_GDIPlus_Startup()'' before using GdiPlus functions? Link to comment Share on other sites More sharing options...
JackDinn Posted May 28, 2009 Share Posted May 28, 2009 (edited) he wouldn't be the first to fall on that 1, if he has done, iv forgotten it loads of times and i think most peeps have at some time. Edited May 28, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
oMBRa Posted May 28, 2009 Share Posted May 28, 2009 he wouldn't be the first to fall on that 1, if he has done, iv forgotten it loads of times and i think most peeps have at some time. I agree Link to comment Share on other sites More sharing options...
Zedna Posted May 28, 2009 Share Posted May 28, 2009 (edited) Look at my Resources UDFhttp://www.autoitscript.com/forum/index.php?showtopic=51103There are techniques used (especially image memory allocation/copy) which you may use. Edited May 28, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
nuki Posted May 28, 2009 Author Share Posted May 28, 2009 haha lolz u guys are great xD what a stupid mistake of course it was _GDIPlus_Startups fault and Zedna i used a function and parts of your UDF ty for that <3 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