GDI+ GetImageEncoders

GDI+ GetImageEncoders

Post by RXJpY » Mon, 08 Nov 2004 10:29:01


I declared the GetImageEncoders the following way:
Private Declare Function GetImageEncoders Lib "gdiplus.dll" Alias
"GdipGetImageEncoders" (ByVal numEncoders As Long, ByVal size As Long,
encoders As ImageCodecInfo) As Long
And I called it by:
Dim encoders as ImageCodecInfo
lRetVal = GetImageEncodersSize(numEncoders, size)
lRetVal = GetImageEncoders(numEncoders, size, encoders)
But I got a "Bad Dll conversion" error

Thank you in advance

Eric
 
 
 

GDI+ GetImageEncoders

Post by Mike D Sut » Mon, 08 Nov 2004 20:29:49

> I declared the GetImageEncoders the following way:
<code snipped>

My guess would be the last parameter, try this instead:

'***
Private Declare Function GetImageEncoders Lib "gdiplus.dll" Alias "GdipGetImageEncoders" ( _
ByVal numEncoders As Long, ByVal size As Long, ByRef encoders As Any) As Long

...

Dim EncodersArr() As Byte, EncoderCount As Long, EncodersSize As Long
Dim LoopEncoders As Long

If (GetImageEncodersSize(EncoderCount, EncodersSize) = 0) Then
ReDim EncodersArr(0 To (EncodersSize - 1)) As Byte
If (GetImageEncoders(EncoderCount, EncodersSize, EncodersArr(0)) = 0) Then

' Use EncodersArr() here

End If
End If
'***

Exactly how you're going to use the data though is another matter, it appears to be returning an array of _objects_ rather than
structures so you'd most likely need a type library to access their data - Have a look at the GDI+ typelibs on www.vbaccelerator and
www.planetsourcecodes.com and see if either do what you're after.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: XXXX@XXXXX.COM
WWW: http://www.yqcomputer.com/