pete_wilde Posted March 16, 2017 Share Posted March 16, 2017 (edited) Hi Guys, I was looking to create a number of single colour images files (don't mind if they are BMP, JPG, PNG or whatever). Fortunately, I came across a neat piece of code which allegedly does just what I want However, when I run the script I get a "variable used without being declared" error in Line 16 I have checked and rechecked the script, but without any success. Is there an eagle-eyed guru out there who can spot the error??? Script is: expandcollapse popup#include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $hGUI = GUICreate("GDI+ Test", 300, 300) Global Const $iPic = GUICtrlCreatePic("", 100, 100, 100, 100) Global Const $hPic = GUICtrlGetHandle($iPic) GUISetBkColor(0x000000, $hGUI) GUISetState() #region GDI+ ;create an empty bitmap Global Const $iWidth = 100, $iHeight = 100 ;dimension of the bitmap Global Const $iStride = 0, $pScan0 = 0, $iPixelFormat = $GDIP_PXF32ARGB ;some bitmap parameters Global $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) Global Const $hBitmap = $aResult[6] ;this is the handle of the new empty bitmap Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;create a context to the bitmap handle to do some GDI+ operations Global Const $iBgColor = 0xFF004488 ;define background color -> ARGB _GDIPlus_GraphicsClear($hContext, $iBgColor) ;clear empty bitmap with new color Global Const $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Step_2_In.png") ;load a transparent PNG image which should be placed on the bitmap _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight) ;copy the image onto the bitmap. if image dimension <> bitmap dimension than the image will be displayed deformed ;save result as JPG and PNG (conversation is done automatically) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\New_Image.jpg") _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\New_Image.png") ;let's display the new created bitmap in the GUI Global Const $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hPic) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, 100, 100) #endregion Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) ;release image _GDIPlus_BitmapDispose($hBitmap) ;release bitmap _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Line16 = Global $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) Basically, all I want to do is to create several BMP files, each one a different colour (e.g. red.bmp, blue.bmp, yellow.bmp, etc) Many thanks Newbie Pete Edited March 16, 2017 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2017 Moderators Share Posted March 16, 2017 pete_wilde, That is an old script - the $ghGDIPDll DLL name was renamed a long time ago to $__g_hGDIPDll. Change that and the error is no more. M23 P.S. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. pete_wilde 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
pete_wilde Posted March 17, 2017 Author Share Posted March 17, 2017 Hi Malba, Perfect :-) Many, many thanks for your help. It is much appreciated. Pete 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