MasonMill Posted April 5, 2014 Posted April 5, 2014 I have been looking in the help file but cant find a function that will tell me the width/height in pixels of an image. Im working with GUIs using the GDI stuff but cant find anything that i can define a variable with a width/height of some random image. Thanks in advance, Maosn
Solution wakillon Posted April 5, 2014 Solution Posted April 5, 2014 I have been looking in the help file but cant find a function that will tell me the width/height in pixels of an image. Im working with GUIs using the GDI stuff but cant find anything that i can define a variable with a width/height of some random image. Thanks in advance, Maosn See help file for GDI functions. #Include <GDIPlus.au3> #Include <Array.au3> _GDIPlus_Startup () $a = _ImageGetDimension ( 'D:\Bureau\pics\123456.jpg' ) _ArrayDisplay ( $a ) _GDIPlus_Shutdown () Func _ImageGetDimension ( $sPicPath ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) Local $hImage = _GDIPlus_ImageLoadFromFile ( $sPicPath ) Local $aRet[2] $aRet[0] = _GDIPlus_ImageGetWidth ( $hImage ) $aRet[1] = _GDIPlus_ImageGetHeight ( $hImage ) _GDIPlus_ImageDispose ( $hImage ) If $aRet[0] And $aRet[1] Then Return $aRet EndFunc ;==> _ImageGetDimension () AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
MasonMill Posted April 5, 2014 Author Posted April 5, 2014 Perfect, ive been looking around but couldnt find it, thanks!
wakillon Posted April 5, 2014 Posted April 5, 2014 Perfect, ive been looking around but couldnt find it, thanks! If you use the help file search with "image get width", you will find the _GDIPlus_ImageGetWidth function at the 25 th position... Glad to help you. AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
UEZ Posted April 5, 2014 Posted April 5, 2014 (edited) As you asked for GDI and not GDI+ here the GDI version:#include <Array.au3> #include <Screencapture.au3> Global $hScreen = _ScreenCapture_Capture("", Random(0, 50, 1), Random(0, 50, 1), Random(100, 500, 1), Random(100, 500, 1)) Global $aDim = _WinAPI_BitmapGetDim($hScreen) _ArrayDisplay($aDim) Func _WinAPI_BitmapGetDim($hHBitmap) Local $tDim = DllStructCreate($tagBITMAP) DllCall("gdi32.dll", "int", "GetObject", "int", $hHBitmap, "int", DllStructGetSize($tDim), "struct*", $tDim) If @error Then Return SetError(1, 0, 0) Local $aDim[2] = [$tDim.bmWidth, $tDim.bmHeight] Return $aDim EndFuncBr,UEZ Edited April 5, 2014 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
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