Questo snippet di codice permette di passare dal formato
di immagini System.Drawing.Image al formato stdole.IPictureDisp.
/// <summary>
/// Perform bidirectional conversions between <see cref="stdole.IPictureDisp"/> and <see cref="System.Drawing.Image"/> formats.
/// </summary>
sealed public class ImageConverter2 : System.Windows.Forms.AxHost
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageConverter2"/> class.
/// </summary>
private ImageConverter2(): base(null) { } // base(""59EE46BA-677D-4d20-BF10-8D8067CB8B32"")
/// <summary>
/// Convert a <see cref="System.Drawing.Image"/> to a <see cref="stdole.IPictureDisp"/>.
/// </summary>
/// <param name="image">The image in <see cref="System.Drawing.Image"/> format.</param>
/// <returns></returns>
public static stdole.IPictureDisp ImageToIPicture(System.Drawing.Image image)
{
return (stdole.IPictureDisp)System.Windows.Forms.AxHost.GetIPictureDispFromPicture(image);
}
/// <summary>
/// Convert a <see cref="stdole.IPictureDisp"/> to a <see cref="System.Drawing.Image"/>.
/// </summary>
/// <param name="picture">The picture in <see cref="stdole.IPictureDisp"/> format.</param>
/// <returns></returns>
public static System.Drawing.Image IPictureToImage(stdole.StdPicture picture)
{
return System.Windows.Forms.AxHost.GetPictureFromIPicture(picture);
}
}
powered by IMHO 1.3