Armag3ddon Posted February 13, 2012 Posted February 13, 2012 (edited) Hi everyone! I've worked my way through the forum but now I'm stuck. I have found lots of code on how to resize images using GDI+ but obviously I do something wrong. I want an element that displays an image in 200x150 pixels but my code crashes on two different lines without further notice. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <StaticConstants.au3> ; Create GUI Global $main = GUICreate("testcase", 800, 600, -1, -1, BitOR($WS_CAPTION, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_THICKFRAME, $DS_CONTEXTHELP, $WS_SYSMENU, $WS_VISIBLE)) Global $graphicview = GUICtrlCreatePic("", 50,5, 200,150, $SS_SUNKEN) _GDIPlus_Startup() $png = StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUITorus.png") ; Insert picture ShowGraphic($png) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func ShowGraphic($file) ; load image $img = _GDIPlus_ImageLoadFromFile($file) $big = _GDIPlus_BitmapCreateHBITMAPFromBitmap($img) ; Resize image $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, 200, 150) _WinAPI_ReleaseDC($hWnd, $hDC) $bmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hGraphics = _GDIPlus_ImageGetGraphicsContext($bmp) ;_GDIPlus_GraphicsDrawImageRect($hGraphics, $big, 0,0, 200,150) ; show image in gui _WinAPI_DeleteObject(GUICtrlSendMsg($graphicview, 0x0172, 0, $bmp)) _GDIPlus_GraphicsDispose($hGraphics) ;_GDIPlus_ImageDispose($big) _WinAPI_DeleteObject($hBMP) EndFunc So this is my test case. I get crashes when I uncomment the following lines (each line crashes separately): _GDIPlus_GraphicsDrawImageRect($hGraphics, $big, 0,0, 200,150) and _GDIPlus_ImageDispose($big) I'm not really sure what I do with GDI+, I mainly copied stuff from the forum, so yeah, I'm lost on this Edited February 13, 2012 by Armag3ddon
Armag3ddon Posted February 13, 2012 Author Posted February 13, 2012 (edited) Argh, copying killed all empty lines and indentation %( /e fixed Edited February 13, 2012 by Armag3ddon
UEZ Posted February 13, 2012 Posted February 13, 2012 Check this out: 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Armag3ddon Posted February 13, 2012 Author Posted February 13, 2012 Well, yeah. I've seen that before and made a futile attempt to reconstruct what you are doing there. Copying would have served me better. Thanks, problem solved
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