Jump to content
Sign in to follow this  
MasonMill

Size of image

Recommended Posts

MasonMill

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

Share this post


Link to post
Share on other sites
wakillon

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.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
MasonMill

Perfect, ive been looking around but couldnt find it, thanks!

Share this post


Link to post
Share on other sites
wakillon

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... :P

Glad to help you.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
UEZ

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
EndFunc

Br,

UEZ ;)

Edited 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Xandy
      By Xandy
      Special thanks: AdmiralAlkex, Melba23, MrCrearoR, Dragon Warrior 3, SDL
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.  
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      A full list of hotkeys can be assigned in the: Help Menu\Hotkeys
       
      MapParser is a C++ project that scans images for unique tiles. 
      MapIt can be downloaded without MapParser. MapParser can be toggled off in the Scan_Image dialog. Without MapParser, MapIt will use the Scan_Tiles() function written in AutoIt ; which is 100 * slower Idk. If MapParser.exe will not run for you:      Installing Visual C++ Redistributable for Visual Studio 2015 should fix it: https://www.microsoft.com/en-us/download/details.aspx?id=48145   
      You can start with example world and tiles.
      Example world was made following these steps:
      Started with a tile map image of DragonWarrior3 town of: Reeve From MapIt World Menu \ New \ Scan_Image dialog, I set the area to exclude the key legend to the far right of image. After scanning the map image to world and tile array.  I removed a few of the map artifacts.  More work could be done on this world; removing unwanted tiles, but it is fine for now. I saved my world to disk.  This creates folder: Worldname: Containing folder of Tiles and a Worldname.txt. Using The Gimp, I edited some tiles to have a transparent color: Stairs, Trees, Desk Tables, Chest-of-drawers, Chairs, Signs, Doors, Beds. I changed the world layers to 2: World Menu \ Properties. F9 Finds all selected tile on current layer and changes to a new selected tile on new layer. I used F9 to change all Trees on layer: 0 to Trees on layer: 1. Then I used F9 to change all Trees on layer: 0 to Grass on layer: 0  
      In this video you can see how I used the Tile Menu \ Replace From Disk option to remap tile images to my custom tiles.  Conveniently my tiles already have a transparent pixel.
      See video for how that was done:
      To use the example world:
      First unzip the world save file: http://songersoft.com/programming/mapit/worlds/Reeve_Swapped.zip From the World Menu: choose \Load Navigate to the Reeve_Swapped.txt located in the extracted zip. Or you can scan any image.
      The map images I used are here: http://www.realmofdarkness.net/dq/games/nes/dw3/maps/world
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
    • Pricehacker
      By Pricehacker
      Hello!
      I want to make a script that changes the filesize of program files while still having them run as usual.
      I tried FileWrite() but then the program wouldnt be recognized as a runnable program, could you guys help me to the right path?
    • Atoxis
      By Atoxis
      Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
      I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

      Anyways, I've looked over the big threads involving imagesearch.

      Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

      Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
      Can't find a working copy so if anyone has one please send it my way lol.

      I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
      Thanks.
    • lenclstr746
      By lenclstr746
      HELLO GUYS
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • dadalt95
      By dadalt95
      I would like to know if it's possible to pass an image recognition (captcha) system.
       
      What are the ways to achieve this?
      Just the references or links is enough for me by now.
       
      Thanks by now!
       
      Thanks!
×