Function Reference


_GDIPlus_ImageGetRawFormat

Returns file format GUID and image format name of an image

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

Parameters

$hImage Handle to an image object

Return Value

Success: an array with the following format:
    [0] - String of file format GUID
    [1] - String of image format name
Failure: sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: 10 - Invalid raw format.
11 - Invalid image handle.
12 - Invalid file format GUID.
13 - Unknown file format GUID.

Related

_GDIPlus_ImageGetType

See Also

Search GdipGetImageRawFormat in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBitmap, $hImage, $aRet

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

    ; Initialize GDI+ library
    _GDIPlus_Startup()

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

    ; Show image format for screen capture
    $aRet = _GDIPlus_ImageGetRawFormat($hImage)
    MemoWrite("Image format of screen capture: " & $aRet[1]);
    MemoWrite("GUID: " & $aRet[0]);
    MemoWrite();

    ; Save screen capture bitmap to file
    _GDIPlus_ImageSaveToFile($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Load screen capture bitmap from file
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Show image format for saved file
    $aRet = _GDIPlus_ImageGetRawFormat($hImage)
    MemoWrite("Image format of saved file: " & $aRet[1]);
    MemoWrite("GUID: " & $aRet[0]);

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    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