dirty Posted September 10, 2011 Posted September 10, 2011 I know one here has to know how to calculate the image size based on #1 Image dimensions #2 Given frame to fin this image #3 this code #include <GDIPlus.au3> $PATH = GUICtrlRead ($MainImagePath) If Not @error Then _GDIPlus_Startup() $IMG = _GDIPlus_ImageLoadFromFile($PATH) $W = _GDIPlus_ImageGetWidth($IMG) $H = _GDIPlus_ImageGetHeight($IMG) _GDIPlus_ImageDispose($IMG) _GDIPlus_Shutdown() MsgBox(0,$PATH,$W & @CRLF & $H) ;size of an image $Image = GUICtrlCreatePic ("F:\Pictures\0106800001a.jpg",405,20,355,275) ;355X275 is area for an image EndIf My image is 1280X960 by my Image area in GUI is smaller, so i want to resize this image to scale its self down till it fits keeping its size ration locked. 1 and most important thing to cincider is that there will be other images with different sizes, so is there a way to make this thing to calculate and scale an image regardless what size to fit into the given frame on my GUI ? Thanks so much in advance. Hope to get the formula soon or something
Yashied Posted September 10, 2011 Posted September 10, 2011 #Include <Math.au3> $ImageWidth = 1280 $ImageHeight = 960 $AreaWidth = 355 $AreaHeight = 275 $Scale = _Min($AreaWidth / $ImageWidth, $AreaHeight / $ImageHeight) $NewImageWidth = $ImageWidth * $Scale $NewImageHeight = $ImageHeight * $Scale ConsoleWrite(Round($NewImageWidth) & 'x' & Round($NewImageHeight) & @CR) dirty 1 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...
UEZ Posted September 11, 2011 Posted September 11, 2011 Look here: Br, 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
dirty Posted September 12, 2011 Author Posted September 12, 2011 Yashied thank you very much.Was most simplified and easy to implement into existing code without having too much new variables.
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