Example #1
0
        /// <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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
 /// <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));
 }
Example #4
0
 /// <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);
     }
 }
Example #5
0
        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");
                }
            }
        }