How to handle StdPicture or Picture in C#?

Use activex controls in C#...

1. How to return a StdPicture type from a file path?

Remember to refer to stdole2.tlb in the system32 directory, 

Export the OleLoadPictureFile function

 [DllImport("oleaut32.dll", CharSet = CharSet.Unicode, PreserveSig =
true, EntryPoint = "OleLoadPictureFile")]
        static extern void OleLoadPictureFile(Object varObj,[ MarshalAs(
UnmanagedType.IDispatch )] out Object oOut);


And load picture from file now:

 System.String strFile;
 strFile = "C:\\Devel\\Inabyte\\Inagrid\\Samples\\VSNet\\CSharp\\InaOwnerDraw\\icon.bmp";
 Object lpDisp = null;
 OleLoadPictureFile((Object) strFile, out lpDisp);
 stdole.StdPicture pic = (stdole.StdPicture)lpDisp;
 

2. How to convert Image to StdPicture or IPictureDisp?

sealed  class ConvertImage : System.Windows.Forms.AxHost
 {
  private ConvertImage() : base(null){}
  public static stdole.IPictureDisp
   Convert(System.Drawing.Image image)
  {
   return (stdole.IPictureDisp)
    System.Windows.Forms.AxHost
    .GetIPictureDispFromPicture(image);

  }
 

 public static stdole.StdPicture
   Convert(System.Drawing.Image image)
  {
   return (stdole.StdPicture)(stdole.IPictureDisp)
    System.Windows.Forms.AxHost
    .GetIPictureDispFromPicture(image);

  }


 }