John117 Posted December 14, 2007 Posted December 14, 2007 looks like you are making a photo editor. not bad! It could use some work, but I think you are getting close. be sure to take a look at the reverse button. Good luck withit.
xzaz Posted December 14, 2007 Author Posted December 14, 2007 hehe, try this photo:http://www.slagerijankersmit.nl/pics/BBQ_All_inn.JPGI cant get him scaled like this: Small Color Picker v0.2 | Travian bot
John117 Posted December 14, 2007 Posted December 14, 2007 (edited) hehe, try this photo:http://www.slagerijankersmit.nl/pics/BBQ_All_inn.JPGI cant get him scaled like this: remember my theory about if both are larger than width and height and not equal then it wouldn't work as is . . . I was right. -I'll look into it shortly Edited December 14, 2007 by Hatcheda
weaponx Posted December 14, 2007 Posted December 14, 2007 I have a sudden craving for shishkabobs on the grill...
John117 Posted December 14, 2007 Posted December 14, 2007 here ya go expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "_Custom_Exit") $GUI = GUICreate("Unimportant GUI", @DesktopWidth, @DesktopHeight, Default, Default, $WS_POPUPWINDOW) $oImage = ObjCreate("WIA.ImageFile") $s_Path = FileOpenDialog("Select Gif Image", @ScriptDir, "Gif Images (*.jpg)") $oImage.LoadFile ($s_Path) $HorizontalRes = $oImage.Width $VerticalRes = $oImage.Height If $oImage.Width > @DesktopWidth Or $oImage.Height > @DesktopHeight Then If $oImage.Width > @DesktopWidth And $oImage.Height > @DesktopHeight And $oImage.Width <> $oImage.Height Then If $oImage.Width > $oImage.Height Then $HorizontalRes = @DesktopWidth $HorizontalResPerc = (1 - (($oImage.Width - @DesktopWidth) / $oImage.Width)) $VerticalRes = $oImage.Height * ($HorizontalResPerc) Else $VerticalRes = @DesktopHeight $VerticalResPerc = (1 - (($oImage.Height - @DesktopHeight) / $oImage.Height)) $HorizontalRes = $oImage.Width * ($VerticalResPerc) EndIf EndIf Else If $oImage.Width > @DesktopWidth Then $HorizontalRes = @DesktopWidth $HorizontalResPerc = (1 - (($oImage.Width - @DesktopWidth) / $oImage.Width)) $VerticalRes = $oImage.Height * ($HorizontalResPerc) ElseIf $oImage.Height > @DesktopHeight Then $VerticalRes = @DesktopHeight $VerticalResPerc = (1 - (($oImage.Height - @DesktopHeight) / $oImage.Height)) $HorizontalRes = $oImage.Width * ($VerticalResPerc) EndIf EndIf ;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] ) $Pic = GUICtrlCreatePic($s_Path, Default, Default, $HorizontalRes, $VerticalRes) GUISetState(@SW_SHOW, $GUI) ; ============================================================================ ; Main Loop ; ============================================================================ While 1 Sleep(10) WEnd ; ============================================================================ ; Functions ; ============================================================================ Func _Custom_Exit() Exit EndFunc ;==>_Custom_Exit
John117 Posted December 14, 2007 Posted December 14, 2007 Assuming that worked for you. it scales a smaller/smaller, larger/smaller, and larger/larger<>
xzaz Posted December 15, 2007 Author Posted December 15, 2007 Assuming that worked for you. it scales a smaller/smaller, larger/smaller, and larger/larger<>This going to far for me , it works with the height now, but not realy with the width. Small Color Picker v0.2 | Travian bot
Xandl Posted December 15, 2007 Posted December 15, 2007 Hello, here is an example for scaling. Just drag an image to the window, it will be shown in original size first. After a short pause, the image will be scaled to the windows dimension. Same happens at maximize and resize. The scaling is in func getScaled(). expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $gWin = GUICreate('imgt',400,300,-1,-1,BitOR($WS_OVERLAPPEDWINDOW,$WS_CLIPSIBLINGS,$WS_SYSMENU),$WS_EX_ACCEPTFILES) GUICtrlCreateLabel('',0,0,400,300) GUICtrlSetState(-1,$GUI_ACCEPTFILES) $gImg = GUICtrlCreatePic(@ProgramFilesDir & '\Messenger\lvback.gif',0,0,0,0) GUICtrlSetState(-1,$GUI_ACCEPTFILES) GUISetState() While 1 Sleep(10) Switch GUIGetMsg() Case $GUI_EVENT_DROPPED setNewImg(@GUI_DragFile) Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE resizeImg($gImg) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func setNewImg($sImgPath) GUICtrlDelete($gImg) $gImg = GUICtrlCreatePic($sImgPath,0,0,0,0) GUICtrlSetState(-1,$GUI_ACCEPTFILES) ToolTip('original size') sleep(800) resizeImg($gImg) ToolTip('scaled size') sleep(800) ToolTip('') EndFunc Func resizeImg($ctrl) Local $aImgPos = ControlGetPos('imgt','',$ctrl) Local $aWinPos = WinGetClientSize('imgt') Local $aPos = getScaled($aImgPos[2],$aImgPos[3],$aWinPos[0],$aWinPos[1]) GUICtrlSetPos($ctrl,0,0,$aPos[0],$aPos[1]) EndFunc Func getScaled($iWidth,$iHeight,$xMax,$yMax) If $xMax/$iWidth > $yMax/$iHeight Then Local $a[2] = [($yMax/$iHeight)*$iWidth,$yMax] Return $a Else Local $a[2] = [$xMax,($xMax/$iWidth)*$iHeight] Return $a EndIf EndFunc ciao Xandl
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