Function Reference


Returns horizontal resolution in DPI (pixels per inch) of an image

#include <GDIPlus.au3>
_GDIPlus_ImageGetHorizontalResolution ( $hImage )


$hImage Handle to an image object

Return Value

Success: an integer of DPI (pixels per inch).
Failure: 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: 10 - DPI cannot be retrieved.
11 - Invalid image handle.



See Also

Search GdipGetImageHorizontalResolution in MSDN Library.


#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPIHObj.au3>
#include <WindowsConstants.au3>

Global $g_idMemo


Func Example()
    Local $hBitmap, $hImage

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    ; Initialize GDI+ library

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show horizontal resolution in DPI (dots per inch) of image
    MemoWrite("HorizontalResolution DPI : " & _GDIPlus_ImageGetHorizontalResolution($hImage));

    ; Clean up resources

    ; Shut down GDI+ library

    ; Loop until the user exits.
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite