/// <summary> /// Construct a IPicture from an array of bytes /// returned IPicture is tagged to be owned by NativeCode, which should dispose of it. /// </summary> public IPicture ImageFromBytes(byte[] pbData, int cbData) { var ret = ImagePicture.ImageBytes(pbData, cbData); ret.ReferenceOwnedByNative = true; return(ret); }
/// <summary> /// Construct a ImagePicture from a C# Image object /// </summary> public static ImagePicture FromImage(Image img) { ImagePicture ret = new ImagePicture(); ret.m_img = (Image)img.Clone(); return(ret); }
/// <summary> /// convert an Image to an OLE Picture IPictureDisp interface /// </summary> /// <param name="image"></param> /// <returns></returns> public static IPictureDisp ToOLE_IPictureDisp(Image image) { if (Platform.IsWindows) { return(AxHost.GetIPictureDispFromPicture(image) as IPictureDisp); } return(ImagePicture.FromImage(image)); }
/// <summary> /// Construct a ImagePicture from an array of bytes /// </summary> public static ImagePicture ImageBytes(byte[] pbData, int cbData) { using (var s = new MemoryStream(pbData, 0, cbData)) { ImagePicture ret = new ImagePicture(); ret.m_img = Image.FromStream(s); return(ret); } }
public void ImagePictureClass() { const int width = 100; const int height = 200; using (Image testImage = new Bitmap(width, height)) { using (ImagePicture i = ImagePicture.FromImage(testImage)) { Assert.AreEqual(new HiMetric(width, i.DpiX).Value, i.Width, "A1"); Assert.AreEqual(new HiMetric(height, i.DpiY).Value, i.Height, "A2"); } } }