I am unable to use the GdipLoadImageFromStream,
the function always fails because of invalid parameter in the
IStream interface (I have never been comfortable with COM)
------------------
Patrice Terrier
mailto
[email protected][email protected]</A>
www.zapsolution.com
Addons: WinLIFT (Skin Engine), GDI+ helper (Graphic package), Artwork (logo creation)
the function always fails because of invalid parameter in the
IStream interface (I have never been comfortable with COM)
Code:
TYPE GdiplusStartupInput GdiplusVersion AS LONG ' Must be 1 DebugEventCallback AS LONG ' Ignored on free builds SuppressBackgroundThread AS LONG ' FALSE unless you're prepared to call ' the hook/unhook functions properly SuppressExternalCodecs AS LONG ' FALSE unless you want GDI+ only to use ' its internal image codecs. END TYPE DECLARE FUNCTION GdiplusStartup LIB "gdiplus.dll" ALIAS "GdiplusStartup" (token&, inputbuf AS GdiplusStartupInput, OPTIONAL BYVAL outputbuf&) AS LONG DECLARE FUNCTION GdiplusShutdown LIB "gdiplus.dll" ALIAS "GdiplusShutdown" (BYVAL token&) AS LONG DECLARE FUNCTION GdipLoadImageFromStream LIB "gdiplus.dll" ALIAS "GdipLoadImageFromStream" (BYVAL stream AS DWORD, nImage&) AS LONG DECLARE FUNCTION CreateStreamOnHGlobal LIB "ole32.dll" ALIAS "CreateStreamOnHGlobal" (BYVAL hGlobal AS DWORD, BYVAL fDeleteOnRelease AS DWORD, pstm AS DWORD) AS LONG FUNCTION GdipStart() EXPORT AS LONG DIM GpInput AS GdiplusStartupInput GpInput.GdiplusVersion = 1 IF GdiplusStartup(hGDIplus&, GpInput) = 0 THEN FUNCTION = hGDIplus& END FUNCTION SUB GdipEnd(BYVAL hGDIplus&) IF hGDIplus& THEN CALL GdiplusShutdown(hGDIplus&): hGDIplus& = 0 END SUB FUNCTION IUnknown_Release (BYVAL pthis AS DWORD PTR) AS DWORD LOCAL DWRESULT AS DWORD IF pthis THEN CALL DWORD @@pthis[2] USING IUnknown_Release(pthis) TO DWRESULT FUNCTION = DWRESULT END IF END FUNCTION FUNCTION PBMAIN() DIM IStream AS DWORD DIM hImage AS LONG, hGDIplus AS LONG hGDIplus = GdipStart sFilename$ = "genus.jpg" hFile& = FreeFile Open sFilename$ For Binary Access Read Shared As #hFile& ReDim m_ImageData(0 To LOF(hFile&) - 1) AS BYTE Get #hFile&, , m_ImageData(0) Close #hFile& If CreateStreamOnHGlobal(m_ImageData(0), BYVAL 0&, IStream) = 0 Then Ret& = GdipLoadImageFromStream([b]IStream[/b], hImage) IF Ret& Then MSGBOX "Couldn't Load Image" + str$(Ret&) ' %GpStatusInvalidParameter = 2 else MSGBOX "It's good" End If CALL IUnknown_Release(IStream) End If CALL GdipEnd(hGDIplus) END FUNCTION
------------------
Patrice Terrier
mailto

www.zapsolution.com
Addons: WinLIFT (Skin Engine), GDI+ helper (Graphic package), Artwork (logo creation)
Comment