Re: Return a Bitmap as IPicture

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Yoavo,

System.Drawing.Bitmap does not implement the OLE IPicture interface. You'll
have to create your own implementation of that interface to wrap the Bitmap
object.

Actually, just on a hunch I searched for IPicture in the VS.NET 2005 object
browser and I discovered the following method:

System.Windows.Forms.AxHost.GetIPictureFromPicture(System.Drawing.Image)

Take a look at some of the other AxHost methods that deal with IPicture as
well. They may come in handy.

- Dave Sexton

"Yoavo" <yoav@xxxxxxxxxxxxxx> wrote in message
news:O%232vd3cpGHA.1440@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I am writing a COM class in c# which needs to implement an interface which
one of its methods declared in the following way:
public stdole.IPicture GetBitmap()
{
}

I have a bitmap (MyBitmap.bmp) in my c# application and I want to load it,
and return it as a return value of the method GetBitmap.
I created a System.Drawing.Bitmap object and load it with MyBitmap.bmp
file.
Now, I tried to convert my Bitmap object to stdole.IPicture, but I dont
know how to do it.

Can someone please help (or suggest a different approach) ?

thanks,
Yoav.




.



Relevant Pages

  • Re: Return a Bitmap as IPicture
    ... System.Drawing.Bitmap does not implement the OLE IPicture interface. ... I created a System.Drawing.Bitmap object and load it with MyBitmap.bmp ... Now, I tried to convert my Bitmap object to stdole.IPicture, but I dont ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Two problems with IPicture
    ... As per the Loadpic KB example I can load bmp's using the OleLoadPicture ... function to create an IPicture. ... Did you create a Stream object and then load the bitmap from there with OleLoadPicture like below?: ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Return a Bitmap as IPicture
    ... private class ImageOLEConverter: AxHost ... System.Drawing.Bitmap does not implement the OLE IPicture interface. ... Now, I tried to convert my Bitmap object to stdole.IPicture, but I dont ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CBitmap to IPIcture.... How?
    ... CBitmap bmp; ... // Create the IPicture from the bitmap handle ... IPicture * pPicture = NULL; ...
    (microsoft.public.vc.mfc)
  • Re: fire event & IUnknown
    ... You should not declare an explicit interface derived from ... IUnknown as a parameter to a method within a dispinterface. ... > IPicture pointer. ...
    (microsoft.public.vc.atl)