MattTheHuman Posted March 17, 2013 Share Posted March 17, 2013 I have a program that randomizes items for a game, and what I would like is to take the pictures and create one picture from around 7 images. Is there a way of doing this?This is my program:And what I would like to end up with is something like this:After the advice from Melba23 I had a look at this topic, Grouping multiple images into one control., but I couldn't make heads or tails of the code. I've messed with some things but nothing has given me the result I wanted. I also would like to save this image to the same dir as the exe overwriting the old image.-MattTheHuman Link to comment Share on other sites More sharing options...
PhoenixXL Posted March 17, 2013 Share Posted March 17, 2013 (edited) of course there is a way, just want to, if know are you interacting with the game for this, If yes I fear you won't receive any help according to the Rules (bottom right corner) Edited March 17, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 17, 2013 Moderators Share Posted March 17, 2013 PhoenixXL, The OP mentioned that a Mod has already offered advice in this endeavour - I would have thought that was sufficient evidence that the thread is acceptable. But just to be clear - I am content for members to assist the OP - as far as I can see from the evidence of the earlier thread this script does not interact with a game. M23 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...
UEZ Posted March 17, 2013 Share Posted March 17, 2013 (edited) MattTheHuman, try this: expandcollapse popup#include <GDIPlus.au3> _GDIPlus_Startup() Global $sPrefix = @ScriptDir & "\" Global $aImages[9] = [$sPrefix & "1.png", "", "", $sPrefix & "2.png", $sPrefix & "3.png", $sPrefix & "4.png", $sPrefix & "5.png", $sPrefix & "6.png", $sPrefix & "7.png"] $iResult = _GDIPlus_AssembleImages($aImages, @ScriptDir & "\Assembled.jpg") If Not @error Then ShellExecute(@ScriptDir & "\Assembled.jpg") _GDIPlus_Shutdown() Exit Func _GDIPlus_AssembleImages($aFiles, $sFile, $iColumn = 3, $iRow = 3, $iW = 72, $iH = 72, $iInterpolation = 7) ;coded by UEZ 2013 If Not IsArray($aFiles) Then Return SetError(1, 0, 0) If $sFile = "" Then Return SetError(2, 0, 0) If UBound($aFiles) <> ($iColumn * $iRow) Then Return SetError(3, 0, 0) ;amount of images must be the same as column * row Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW * $iColumn, $iH * $iRow) ;create a new empty bitmap Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get handle to the empty bitmap _GDIPlus_GraphicsSetInterpolationMode($hContext, $iInterpolation) ;set interpolation mode to get better quality on resized images Local $x, $y, $i = 0, $hBmp For $y = 0 To $iRow - 1 ;fill images to the empty bitmap For $x = 0 To $iColumn - 1 If $aFiles[$i] <> "" Then $hBmp = _GDIPlus_BitmapCreateFromFile($aFiles[$i]) ;load image If $hBmp Then _GDIPlus_GraphicsDrawImageRect($hContext, $hBmp, $x * $iW, $y * $iH, $iW, $iH) ;copy image to the appropriate position _GDIPlus_BitmapDispose($hBmp) ;dispose temp image otherwise memory leak EndIf $i += 1 Next Next _GDIPlus_GraphicsDispose($hContext) ;dispose graphic context _GDIPlus_ImageSaveToFile($hBitmap, $sFile) ;save new created image If @error Then _GDIPlus_BitmapDispose($hBitmap) Return SetError(4, 0, 0) EndIf _GDIPlus_BitmapDispose($hBitmap) Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _GDIPlus_BitmapCreateFromScan0 ; Description ...: Creates a Bitmap object based on an array of bytes along with size and format information ; Syntax.........: _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight[, $iStride = 0[, $iPixelFormat = 0x0026200A[, $pScan0 = 0]]]) ; Parameters ....: $iWidth - The bitmap width, in pixels ; $iHeight - The bitmap height, in pixels ; $iStride - Integer that specifies the byte offset between the beginning of one scan line and the next. This ; +is usually (but not necessarily) the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) ; +multiplied by the width of the bitmap. The value passed to this parameter must be a multiple of four ; $iPixelFormat - Specifies the format of the pixel data. Can be one of the following: ; |$GDIP_PXF01INDEXED - 1 bpp, indexed ; |$GDIP_PXF04INDEXED - 4 bpp, indexed ; |$GDIP_PXF08INDEXED - 8 bpp, indexed ; |$GDIP_PXF16GRAYSCALE - 16 bpp, grayscale ; |$GDIP_PXF16RGB555 - 16 bpp; 5 bits for each RGB ; |$GDIP_PXF16RGB565 - 16 bpp; 5 bits red, 6 bits green, and 5 bits blue ; |$GDIP_PXF16ARGB1555 - 16 bpp; 1 bit for alpha and 5 bits for each RGB component ; |$GDIP_PXF24RGB - 24 bpp; 8 bits for each RGB ; |$GDIP_PXF32RGB - 32 bpp; 8 bits for each RGB. No alpha. ; |$GDIP_PXF32ARGB - 32 bpp; 8 bits for each RGB and alpha ; |$GDIP_PXF32PARGB - 32 bpp; 8 bits for each RGB and alpha, pre-mulitiplied ; $pScan0 - Pointer to an array of bytes that contains the pixel data. The caller is responsible for ; +allocating and freeing the block of memory pointed to by this parameter. ; Return values .: Success - Returns a handle to a new Bitmap object ; Failure - 0 and either: ; |@error and @extended are set if DllCall failed ; |$GDIP_STATUS contains a non zero value specifying the error code ; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources ; Related .......: _GDIPlus_ImageDispose ; Link ..........; @@MsdnLink@@ GdipCreateBitmapFromScan0 ; Example .......; Yes ; =============================================================================================================================== Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 ; #FUNCTION# ==================================================================================================================== ; Name...........: _GDIPlus_GraphicsSetInterpolationMode ; Description ...: Sets the interpolation mode of a Graphics object ; Syntax.........: _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode) ; Parameters ....: $hGraphics - Pointer to a Graphics object ; $iInterpolationMode - Interpolation mode: ; |0 - Default interpolation mode ; |1 - Low-quality mode ; |2 - High-quality mode ; |3 - Bilinear interpolation. No prefiltering is done ; |4 - Bicubic interpolation. No prefiltering is done ; |5 - Nearest-neighbor interpolation ; |6 - High-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking ; |7 - High-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking ; Return values .: Success - True ; Failure - False and either: ; |@error and @extended are set if DllCall failed ; |$GDIP_STATUS contains a non zero value specifying the error code ; Remarks .......: The interpolation mode determines the algorithm that is used when images are scaled or rotated ; Related .......: _GDIPlus_GraphicsGetInterpolationMode ; Link ..........; @@MsdnLink@@ GdipSetInterpolationMode ; Example .......; No ; =============================================================================================================================== Func _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hGraphics, "int", $iInterpolationMode) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_GraphicsSetInterpolationMode Br, UEZ Edited March 17, 2013 by 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...
MattTheHuman Posted March 17, 2013 Author Share Posted March 17, 2013 MattTheHuman, try this: expandcollapse popup#include <GDIPlus.au3> _GDIPlus_Startup() Global $sPrefix = @ScriptDir & "\" Global $aImages[9] = [$sPrefix & "1.png", "", "", $sPrefix & "2.png", $sPrefix & "3.png", $sPrefix & "4.png", $sPrefix & "5.png", $sPrefix & "6.png", $sPrefix & "7.png"] $iResult = _GDIPlus_AssembleImages($aImages, @ScriptDir & "\Assembled.jpg") If Not @error Then ShellExecute(@ScriptDir & "\Assembled.jpg") _GDIPlus_Shutdown() Exit Func _GDIPlus_AssembleImages($aFiles, $sFile, $iColumn = 3, $iRow = 3, $iW = 72, $iH = 72, $iInterpolation = 7) ;coded by UEZ 2013 If Not IsArray($aFiles) Then Return SetError(1, 0, 0) If $sFile = "" Then Return SetError(2, 0, 0) If UBound($aFiles) <> ($iColumn * $iRow) Then Return SetError(3, 0, 0) ;amount of images must be the same as column * row Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW * $iColumn, $iH * $iRow) ;create a new empty bitmap Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get handle to the empty bitmap _GDIPlus_GraphicsSetInterpolationMode($hContext, $iInterpolation) ;set interpolation mode to get better quality on resized images Local $x, $y, $i = 0, $hBmp For $y = 0 To $iRow - 1 ;fill images to the empty bitmap For $x = 0 To $iColumn - 1 If $aFiles[$i] <> "" Then $hBmp = _GDIPlus_BitmapCreateFromFile($aFiles[$i]) ;load image If $hBmp Then _GDIPlus_GraphicsDrawImageRect($hContext, $hBmp, $x * $iW, $y * $iH, $iW, $iH) ;copy image to the appropriate position _GDIPlus_BitmapDispose($hBmp) ;dispose temp image otherwise memory leak EndIf $i += 1 Next Next _GDIPlus_GraphicsDispose($hContext) ;dispose graphic context _GDIPlus_ImageSaveToFile($hBitmap, $sFile) ;save new created image If @error Then _GDIPlus_BitmapDispose($hBitmap) Return SetError(4, 0, 0) EndIf _GDIPlus_BitmapDispose($hBitmap) Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _GDIPlus_BitmapCreateFromScan0 ; Description ...: Creates a Bitmap object based on an array of bytes along with size and format information ; Syntax.........: _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight[, $iStride = 0[, $iPixelFormat = 0x0026200A[, $pScan0 = 0]]]) ; Parameters ....: $iWidth - The bitmap width, in pixels ; $iHeight - The bitmap height, in pixels ; $iStride - Integer that specifies the byte offset between the beginning of one scan line and the next. This ; +is usually (but not necessarily) the number of bytes in the pixel format (for example, 2 for 16 bits per pixel) ; +multiplied by the width of the bitmap. The value passed to this parameter must be a multiple of four ; $iPixelFormat - Specifies the format of the pixel data. Can be one of the following: ; |$GDIP_PXF01INDEXED - 1 bpp, indexed ; |$GDIP_PXF04INDEXED - 4 bpp, indexed ; |$GDIP_PXF08INDEXED - 8 bpp, indexed ; |$GDIP_PXF16GRAYSCALE - 16 bpp, grayscale ; |$GDIP_PXF16RGB555 - 16 bpp; 5 bits for each RGB ; |$GDIP_PXF16RGB565 - 16 bpp; 5 bits red, 6 bits green, and 5 bits blue ; |$GDIP_PXF16ARGB1555 - 16 bpp; 1 bit for alpha and 5 bits for each RGB component ; |$GDIP_PXF24RGB - 24 bpp; 8 bits for each RGB ; |$GDIP_PXF32RGB - 32 bpp; 8 bits for each RGB. No alpha. ; |$GDIP_PXF32ARGB - 32 bpp; 8 bits for each RGB and alpha ; |$GDIP_PXF32PARGB - 32 bpp; 8 bits for each RGB and alpha, pre-mulitiplied ; $pScan0 - Pointer to an array of bytes that contains the pixel data. The caller is responsible for ; +allocating and freeing the block of memory pointed to by this parameter. ; Return values .: Success - Returns a handle to a new Bitmap object ; Failure - 0 and either: ; |@error and @extended are set if DllCall failed ; |$GDIP_STATUS contains a non zero value specifying the error code ; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources ; Related .......: _GDIPlus_ImageDispose ; Link ..........; @@MsdnLink@@ GdipCreateBitmapFromScan0 ; Example .......; Yes ; =============================================================================================================================== Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 ; #FUNCTION# ==================================================================================================================== ; Name...........: _GDIPlus_GraphicsSetInterpolationMode ; Description ...: Sets the interpolation mode of a Graphics object ; Syntax.........: _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode) ; Parameters ....: $hGraphics - Pointer to a Graphics object ; $iInterpolationMode - Interpolation mode: ; |0 - Default interpolation mode ; |1 - Low-quality mode ; |2 - High-quality mode ; |3 - Bilinear interpolation. No prefiltering is done ; |4 - Bicubic interpolation. No prefiltering is done ; |5 - Nearest-neighbor interpolation ; |6 - High-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking ; |7 - High-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking ; Return values .: Success - True ; Failure - False and either: ; |@error and @extended are set if DllCall failed ; |$GDIP_STATUS contains a non zero value specifying the error code ; Remarks .......: The interpolation mode determines the algorithm that is used when images are scaled or rotated ; Related .......: _GDIPlus_GraphicsGetInterpolationMode ; Link ..........; @@MsdnLink@@ GdipSetInterpolationMode ; Example .......; No ; =============================================================================================================================== Func _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hGraphics, "int", $iInterpolationMode) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] = 0 EndFunc ;==>_GDIPlus_GraphicsSetInterpolationMode Br, UEZ This is perfect. Thank you so much. The explanations are amazing too. I'll learn a lot from this. I'll reference you in my program too, thanks for the help! 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