ssimpson Posted June 3, 2009 Posted June 3, 2009 Does anyone know of a function that would rotate an image from portrait to landscape? Specifically images within a .TIF file. Thanks in advance.
JackDinn Posted June 4, 2009 Posted June 4, 2009 you prob need to look into GDIPlus and _GDIPlus_MatrixRotate () 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
Yashied Posted June 4, 2009 Posted June 4, 2009 http://www.autoitscript.com/forum/index.php?showtopic=95357 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Malkey Posted June 4, 2009 Posted June 4, 2009 Does anyone know of a function that would rotate an image from portrait to landscape? Specifically images within a .TIF file. Thanks in advance.And another way. Note:- Read tool tip. expandcollapse popup; #include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <Misc.au3> Opt('MustDeclareVars', 1) Local $hGUI1, $hGUI2, $hImage, $hGraphic1, $hGraphicGUI Local $w, $h, $hBMPBuff, $hGraphic, $tMP, $Flg = 0 Local $Path = FileOpenDialog("Choose Image File", @DesktopDir & "", _ "Images (*.tif;*.gif;*.jpg;*.png;*.bmp)| All (*.*)", 1, "Test.tif") If Not @error Then _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($Path) Else Exit EndIf ;$hImage = _GDIPlus_ImageLoadFromFile("Fullpath &filename.ext") $w = _GDIPlus_ImageGetWidth($hImage) $h = _GDIPlus_ImageGetHeight($hImage) ;ConsoleWrite("$wx$h = " & $w & "x" & $h & " $hImage = " & $hImage & @CRLF) ; Create a GUI for the original image $hGUI1 = GUICreate("Original", $w, $h, 0, 0) GUISetState() ; Draw original image $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND($hGUI1) _GDIPlus_GraphicsDrawImage($hGraphic1, $hImage, 0, 0) ; Create a GUI for the zoomed image $hGUI2 = GUICreate("Rotated", $h, $w, 0, 400) GUISetState() $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGUI2) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($h, $w, $hGraphicGUI) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) ;_GDIPlus_DrawImagePoints($hGraphic, $hImage, 0, 0, 0, $w, $h, 0); Back2front ;_GDIPlus_DrawImagePoints($hGraphic, $hImage, 0, $w, 0, 0, $h, $w); Upside down _GDIPlus_DrawImagePoints($hGraphic, $hImage, $h, 0, $h, $w, 0, 0); Lanscape ;_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, ($w - $h * $h / $w) / 2, 0, $h, $w, 0, 0, $h * $w / $h, $w * $w / $h);Trim GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ; Loop until user exits Do $tMP = _WinAPI_GetMousePos() If _WinAPI_WindowFromPoint($tMP) = WinGetHandle($hGUI2) Then ToolTip("Ctrl + Left mouse click to save image" & @CRLF & _ "Ctrl + Alt to rotate image", DllStructGetData($tMP, "X") + 5, DllStructGetData($tMP, "Y") - 20) Else ToolTip("") EndIf If _IsPressed("01") And _IsPressed("11") Then;Left click + Ctrl key to save image Do Until Not _IsPressed("01") Local $PathFile = FileSaveDialog("Choose Image File Name", @DesktopDir & "", _ "Images (*.tif;*.png;*.bmp)| All (*.*)", 1, "Porttif.tif") If Not @error Then _GDIPlus_ImageSaveToFile($hBMPBuff, $PathFile) ShellExecute($PathFile) EndIf EndIf If _IsPressed("11") And _IsPressed("12") Then;Ctrl +Alt keys to rotate image Do Until Not (_IsPressed("11") And _IsPressed("12")) $Flg = Mod($Flg + 1, 4) Switch $Flg Case 0 _GDIPlus_DrawImagePoints($hGraphic, $hImage, $h, 0, $h, $w, 0, 0); Lanscape _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) Case 1 _GDIPlus_DrawImagePoints($hGraphic, $hImage, 0, $w, 0, 0, $h, $w); Upside down _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) Case 2 _GDIPlus_DrawImagePoints($hGraphic, $hImage, 0, 0, 0, $w, $h, 0); Back2front _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) Case 3 _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, ($w - $h * $h / $w) / 2, 0, $h, $w, 0, 0, $h * $w / $h, $w * $w / $h);Trim _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) EndSwitch EndIf Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Release resources _GDIPlus_GraphicsDispose($hGraphic1) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hGraphicGUI) _WinAPI_DeleteObject($hBMPBuff) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func MY_PAINT($hWnd, $msg, $wParam, $lParam) ; Check, if the GUI with the Graphic should be repainted If $hWnd = $hGUI2 Then _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) If $hWnd = $hGUI1 Then _GDIPlus_GraphicsDrawImage($hGraphic1, $hImage, 0, 0) Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT ;
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