--- "bluescreenweasel" <peteraddington@...> wrote:
>
> And another one!
>
> I am using a com object interop (DSOfile) in a VB.net project, and in
> order to extract the thumbnail property of a file, I am using another
> reference, visualbasiccompatibility.VB6 and the method
> IpicturetoImage. This seems to be the only way that it converts the
> ole ipciture to a standard VB.net image.
>
> I had thought that using Convert_PictureToBitmap would have replaced
> this but it seems i am getting an "unable to cast" exception when i
> attempt it try. I guess a stdole.stdpicture is not the same as an ole
> Ipicture???. It would be nice if i could do everything in AIL rather
> than have the extra reference if possible. any thoughts?
The "Convert_PictureToBitmap" function takes an StdPicture object in
VB5/VB6, and takes a System.Drawing.Image object in .NET... then
converts it to a Win32 BITMAP handle. I don't think this is what
you're looking for.
In VB5/VB6, the following applies:
- Image = FreeImage handle passed through the AIL interface
- Picture = StdPicture object (native VB5/VB6 image object)
- Bitmap = Win32 BITMAP handle (used natively by Windows API calls)
- DIB = Device Indepentant Bitmap (used natvely by Windows API calls)
In .NET, the following applies:
- Image = FreeImage handle passed through the AIL interface
- Picture = System.Drawing.Image object (native .NET image object)
- Bitmap = Win32 BITMAP handle (used natively by Windows API calls)
- DIB = Device Indepentant Bitmap (used natvely by Windows API calls)
So the "Convert_PictureToBitmap" function you're calling is expecting a
System.Drawing.Image object and returns a handle to a Win32 BITMAP. I
don't think that's what you want.
It sounds to me like the "IpicturetoImage" returns a
System.Drawing.Image object and so you would want to use
the "Convert_PictureToImage" function to convert that
System.Drawing.Image object to a FreeImage handle that can be used by
the other AIL functions.
======
By the way, in VB5/VB6 the "StdPicture" object (part of the "stdole"
library) is interchangeable with the "IPictureDisp" object (also part
of the "stdole" library). In fact, if you look at their interfaces,
they are identical. Have exactly the same properties and methods. You
can declare an StdPicture object and pass it to a function
like "SavePicture" which according to the declaration takes an
IPictureDisp object as a parameter.
Now, just because VB5/VB6 treats them as the same thing does not mean
that .NET will. VB5/VB6 is a lot more forgiving, where .NET is a lot
more strict with typing.
That being said, I've never had a problem passing StdPicture objects
to .NET and having them converted to System.Drawing.Image objects. A
good example of this is a class module I wrote a long time ago
when .NET first came out called "cStdOle":
http://net.thevbzone.com/cStdOle.vb
It was written for .NET 1.x and I've never tried porting it to .NET 2.x
or 3.x... but it might help.
- Kevin