Exemple #1
0
        public string ConvertThumb(string imgbyte)
        {
            System.Drawing.Image OriginalImage;

            OriginalImage = System.Drawing.Image.FromFile(imgbyte);

            var          imThumbnailImage = OriginalImage.GetThumbnailImage(75, 75, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
            MemoryStream myMS             = new MemoryStream();

            imThumbnailImage.Save(myMS, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] test_imge     = myMS.ToArray();
            string directorypath = Path.Combine(Directory.GetCurrentDirectory(), "Thumbnails");

            if (!Directory.Exists(directorypath))
            {
                Directory.CreateDirectory(directorypath);
            }
            Guid   name     = Guid.NewGuid();
            string filePath = Path.Combine(directorypath, name.ToString() + ".jpeg");

            using (Image image = Image.FromStream(new MemoryStream(test_imge)))
            {
                image.Save(filePath, ImageFormat.Jpeg);
            }
            imThumbnailImage.Dispose();
            OriginalImage.Dispose();
            return(filePath);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         OriginalImage?.Dispose();
         Preview?.Dispose();
     }
 }
 public override void Dispose()
 {
     if (OriginalImage != null)
     {
         OriginalImage.Dispose();
         OriginalImage = null;
     }
     FreeFont();
 }
 public void Dispose()
 {
     OriginalImage?.Dispose();
     OriginalImage = null;
     BigImage?.Dispose();
     BigImage = null;
     SmallImage?.Dispose();
     SmallImage = null;
     TinyImage?.Dispose();
     TinyImage = null;
     XtraTinyImage?.Dispose();
     XtraTinyImage = null;
 }
        internal void ClearImage()
        {
            if (OriginalImage != null)
            {
                OriginalImage.Dispose();
                OriginalImage = null;
            }

            if (ThumbImage != null)
            {
                ThumbImage.Dispose();
                ThumbImage = null;
            }

            // this.gridControl1.DataSource = null;
        }
        internal void ShowOriginalImage()
        {
            this.picEditOriginal.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom;
            if (OriginalImage != null)
            {
                OriginalImage.Dispose();
            }

            if (ThumbImage != null)
            {
                ThumbImage.Dispose();
            }

            //OriginalImage = m_Record.OriginalPic == null ? null : m_Record.OriginalPic.Clone() as Image;
            //ThumbImage = m_Record.ObjectPic == null ? null : m_Record.ObjectPic.Clone() as Image;

            AutoFit();
        }
Exemple #7
0
        /// <summary>
        /// Cleans managed and unmanaged resources.
        /// </summary>
        /// <param name="disposing">
        /// If it is <b>true</b>, the method is invoked directly or indirectly from the user code.
        /// If it is <b>false</b>, the method is called the finalizer and only unmanaged resources are finalized.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            // free managed resources
            if (disposing)
            {
                Image = null;
                OriginalImage?.Dispose();
                ProcessedImage?.Dispose();
            }

            // free native resources

            // avoid seconds calls
            _isDisposed = true;
        }
Exemple #8
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (OriginalImage != null)
         {
             OriginalImage.Dispose();
             OriginalImage = null;
         }
         if (ThumbnailImage != null)
         {
             ThumbnailImage.Dispose();
             ThumbnailImage = null;
         }
         if (FilteredImage != null)
         {
             FilteredImage.Dispose();
             FilteredImage = null;
         }
     }
 }
Exemple #9
0
        public byte[] Scale(byte[] byteArray)
        {
            try
            {
                int height = 70;
                int width  = 70;
                //Grab the Original Image From SQL
                Image imThumbnailImage;

                Image        OriginalImage;
                MemoryStream ms = new MemoryStream();

                // Stream / Write Image to Memory Stream from the Byte Array.
                ms.Write(byteArray, 0, byteArray.Length);

                OriginalImage = Image.FromStream(ms);

                // Shrink the Original Image to a thumbnail size.
                imThumbnailImage = OriginalImage.GetThumbnailImage(width, height, new Image.GetThumbnailImageAbort(ThumbnailCallBack), IntPtr.Zero);

                // Save Thumbnail to Memory Stream for Conversion to Byte Array.
                MemoryStream myMS = new MemoryStream();
                imThumbnailImage.Save(myMS, System.Drawing.Imaging.ImageFormat.Jpeg);
                byte[] test_imge = myMS.ToArray();

                // Finally, Update Gallery's Thumbnail.

                imThumbnailImage.Dispose();
                OriginalImage.Dispose();
                return(test_imge);
            }
            catch (Exception ex)
            {
                throw new SystemException("Resize Error.", ex);
            }
        }