AlmarM Posted May 27, 2010 Share Posted May 27, 2010 Hiya! Is there a way to: Load a .jpg file, resize it and save the resized image using GDIPlus? Or any other method? AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Juvigy Posted May 27, 2010 Share Posted May 27, 2010 It can be done fairly easy and simple by using mspaint Link to comment Share on other sites More sharing options...
AlmarM Posted May 27, 2010 Author Share Posted May 27, 2010 It should be fully automatic, without any notice the image is actualy resized. Im currently using FreeImage. $SelectPic = FileOpenDialog("Select picture...", @DesktopDir, "JPG Pictures (*.jpg;*.jpeg)", 3, "", $MainGUI) _FreeImage_LoadDLL(@ScriptDir & "\Resources\FreeImage.dll") _FreeImage_Initialise() $FIF = _FreeImage_GetFileTypeU($SelectPic) If $FIF = $FIF_UNKNOWN Then $FIF = _FreeImage_GetFIFFromFilenameU($SelectPic) EndIf $hImage = _FreeImage_LoadU($FIF, $SelectPic) $Resized = _FreeImage_Rescale($hImage, 320, 460, $FILTER_LANCZOS3) _FreeImage_SaveU($FIF, $Resized, $PicResized) _FreeImage_Unload($hImage) _FreeImage_Unload($Resized) _FreeImage_DeInitialise() Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
jaberwacky Posted May 27, 2010 Share Posted May 27, 2010 You could use ImageMagick. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
AlmarM Posted May 27, 2010 Author Share Posted May 27, 2010 You could use ImageMagick.Eh? Whats ImageMagick?I dont need any software, its just like this:The user selects a JPG file using FileOpenDialog, autoit should load it, resize it and then save it agian. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
AlmarM Posted May 27, 2010 Author Share Posted May 27, 2010 Im currently trying something like this. #include <GDIPlus.au3> $fod = FileOpenDialog("", @DesktopDir, "All files (*.*)") $fsd = FileSaveDialog("", @DesktopDir, "All files (*.*)") _ResizeImage($fod, $fsd, 100, 100) Func _ResizeImage($sFile, $sOutput, $iWidth, $iHeight) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFile) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $iWidth, $iHeight) _GDIPlus_ImageSaveToFile($hImage, $sOutput) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc Isnt working though. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Malkey Posted May 27, 2010 Share Posted May 27, 2010 This works. #include <GDIPlus.au3> Local $fod = FileOpenDialog("", @DesktopDir, "All files (*.*)") Local $fsd = FileSaveDialog("", @DesktopDir, "All files (*.*)") _ResizeImage($fod, $fsd, 100, 100) ShellExecute($fsd) Func _ResizeImage($sFile, $sOutput, $iWidth, $iHeight) Local $hBMP, $hImage1, $hImage2, $hGraphic _GDIPlus_Startup() $hBMP = _WinAPI_CreateBitmap($iWidth, $iHeight, 1, 32) ; Create a bitmap (handle) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ; Create a Bitmap object from a bitmap handle. $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) ; Get the graphic context of the blank bitmap. $hImage2 = _GDIPlus_ImageLoadFromFile($sFile) ; Load the image you want to resize. _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iWidth, $iHeight) ;Draw the loaded image to the graphics of the blank bitmap at the size you want. _GDIPlus_ImageSaveToFile($hImage1, $sOutput) _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() EndFunc ;==>_ResizeImage Link to comment Share on other sites More sharing options...
AlmarM Posted May 27, 2010 Author Share Posted May 27, 2010 Thanks Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. 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