Jump to content

GDIplus


Recommended Posts

I can't seem to get the call to GdipGetImageEncodersSize to work.

I've tried several different param types.

Global Const $GDIP_ERROR[22] = ["Ok", "GenericError", "InvalidParameter", "OutOfMemory", "ObjectBusy", "InsufficientBuffer", "NotImplemented", "Win32Error", "WrongState", "Aborted", "FileNotFound", "ValueOverflow", "AccessDenied", "UnknownImageFormat", "FontFamilyNotFound", "FontStyleNotFound", "NotTrueTypeFont", "UnsupportedGdiplusVersion", "GdiplusNotInitialized", "PropertyNotFound", "PropertyNotSupported", "ProfileNotFound"]
;~ typedef struct _GUID
;~ {
;~     DWORD Data1;
;~     WORD  Data2;
;~     WORD  Data3;
;~     BYTE  Data4[8];
;~ } GUID;
$tagGUID = "dword;short;short;byte[8]"
$tagGdiplusStartupInput = "dword;dword;long;long"
$tagGdiplusStartupOutput = "dword;dword"
$tagImageCodecInfo = StringFormat("%s;%s;%s", $tagGUID, $tagGUID, "dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;dword")
;ConsoleWrite($tagImageCodecInfo&@LF)

;;check for gdi+ dll.  Might not be avail on > Win2k
$dll = DllOpen("gdiplus.dll")
If Not $dll Then
    ConsoleWrite("GDI plus not accessable." & @LF)
    Exit
EndIf
DllClose($dll)

;Simple test to get encoders size.
GDIPTest()

Exit
Func GDIPTest()
    Local $token = DllStructCreate("int")
    Local $StartupInput = DllStructCreate($tagGdiplusStartupInput)
    ;Local $StartupOutput = DllStructCreate($tagGdiplusStartupOutput)
    DllStructSetData($StartupInput, 1, 1); set GDI+ version to 1
    Local $nStatus = GdiplusStartup($token, $StartupInput, 0)
    If $nStatus Then
        ConsoleWrite("Error initializing GDI+" & @LF & "Error was: " & $GDIP_ERROR[$nStatus] & @LF)
        $StartupInput = 0 
        $StartupOutput = 0
        Exit
    EndIf
;~    Local $numEncoders = DllStructCreate("dword")
;~     Local $nSize = DllStructCreate("dword")
   Local $numEncoders = DllStructCreate("uint")
    Local $nSize = DllStructCreate("uint")
    
    $nStatus = GdipGetImageEncodersSize($numEncoders,$nSize)
    $v_err = @error
    If $v_err or $nStatus Then
        $StartupInput = 0 
        $StartupOutput = 0
        $numEncoders = 0
        $nSize = 0
        if $v_err Then 
            ConsoleWrite("There was an error. @error="&@error&@LF)
        Else
            ConsoleWrite("Error Getting EncodersSize GDI+" & @LF & "Error was: " & $GDIP_ERROR[$nStatus] & @LF)
        EndIf
    Else
    ConsoleWrite(DllStructGetdata($numEncoders,1)&@LF)
    ConsoleWrite(DllStructGetdata($nSize,1)&@LF)
    EndIf
    GdiplusShutdown($token)
    $StartupInput = 0 
    $StartupOutput = 0
    $numEncoders = 0
    $nSize = 0
    Exit

EndFunc

Func GdiplusStartup(ByRef $token, ByRef $inputbuf,$outputbuf=0)
    Local $v_ret
    $v_ret = _API(DllCall("gdiplus.dll", "long", "GdiplusStartup", "ptr", DllStructGetPtr($token), "ptr", DllStructGetPtr($inputbuf), "int", 0))
    ConsoleWrite("Call:" & @error&@LF)
    ConsoleWrite("GDIStartup:"& $v_ret & @LF)
    Return $v_ret
EndFunc   ;==>GdiplusStartup

Func GdiplusShutdown($token)
    Local $v_ret
    $v_ret = _API(DllCall("gdiplus.dll", "none", "GdiplusStartup", "dword", $token))
    Return $v_ret
EndFunc   ;==>GdiplusShutdown

Func GdipGetImageEncodersSize(ByRef $numEncoders, ByRef $nSize)
     Local $v_ret,$v_err
    $v_ret = DllCall("gdiplus.dll", "int", "GdipGetImageEncodersSize", "ptr", DllStructGetPtr($numEncoders), "ptr", DllStructGetPtr($nSize))
    $v_err = @error
    ConsoleWrite("Return Error="&$v_err&@LF)
    if $v_err Then Return (SetError($v_err))
    $v_ret = _API($v_ret)
    Return $v_ret
EndFunc   ;==>GdipGetImageEncodersSize

Func _API($v_ret)
    If IsArray($v_ret) Then
        Return $v_ret[0]
    Else
        Return $v_ret
    EndIf
EndFunc   ;==>_API

oÝ÷ Ù«­¢+Ø(ÐìÅÕ½ÐíèÀäÈíAɽɴ¥±ÌÀäÈíM¥¹Ñ¥±±QáХѽÈÀäÈíÕѽ%ÐÍ]ÉÁÁÈÀäÈíÕѽ%ÐÍ]ÉÁÁȹáÅÕ½Ðì½ÉÕ¸½Áɽ½ÉɽÉMÑ=Õн¥¸ÅÕ½ÐíèÀäÈíAɽɴ¥±ÌÀäÈíÕѽ%ÐÌÀäÈíMÉ¥ÁÑÌÀäÈí¥ÁÑÍйÔÌÅÕ½Ðì½Õѽ¥ÐÍ¥ÈÅÕ½ÐíèÀäÈíAɽɴ¥±ÌÀäÈíÕѽ%ÐÌÅÕ½Ðì½UÍÉAɵÌ(ÐíIÕ¹¹¥¹TÍ
¡¬ ĸÔиظÀ¤ÁɵÌèɽ´éèÀäÈíAɽɴ¥±ÌÀäÈíÕѽ%ÐÌ(¬ÐíTÍ
¡¬¹¹ÉèÀ(ÐíIÕ¹¹¥¹è ̸ȸȸÀ¤éèÀäÈíAɽɴ¥±ÌÀäÈíÕѽ%ÐÌÀäÈíÕѽ¥Ð̹áÅÕ½ÐíèÀäÈíAɽɴ¥±ÌÀäÈíÕѽ%ÐÌÀäÈíMÉ¥ÁÑÌÀäÈí¥ÁÑÍйÔÌÅÕ½Ðì)
±°èÀ)%MÑÉÑÕÀèÀ)èÀäÈíAɽɴ¥±ÌÀäÈíÕѽ%ÐÌÀäÈíMÉ¥ÁÑÌÀäÈí¥ÁÑÍйÔÌ àÔ¤èôôÐìÕѽ%С̹½Õ¹ÑÉÑ°ÉÍ ÌÉÍձнè(U¹±Ñ¼áÕÑ11
±°¸è(ÀÌØíÙ}ÉÐô±±
±° ÅÕ½Ðí¥Á±Õ̹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí¥ÁÑ%µ¹½ÉÍM¥éÅÕ½Ðì°ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±MÑÉÕÑÑAÑÈ ÀÌØí¹Õµ¹½É̤°ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±MÑÉÕÑÑAÑÈ ÀÌØí¹M¥é¤¤(¬ÐíÕѽ%P̹ṹÉèÀ(Ðíá¥Ð½èÀQ¥µèĸØÌ

Any help would be greatly appreciated.

eltorro

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...