Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GifDecoder"/> class.
        /// </summary>
        /// <param name="image">The image to decode.</param>
        public GifDecoder(Gif image)
        {
            this.image            = image;
            this.ActiveFrameIndex = 0;

            if (ImageAnimator.CanAnimate(image))
            {
                this.IsAnimated = true;
                this.FrameCount = image.Image.GetFrameCount(FrameDimension.Time);
                const int LoopCount  = (int)ExifPropertyTag.LoopCount;
                const int FrameDelay = (int)ExifPropertyTag.FrameDelay;

                // Loop info is stored at byte 20737. Default to infinite loop if not found.
                this.LoopCount = Array.IndexOf(image.Image.PropertyIdList, LoopCount) != -1
                    ? BitConverter.ToInt16(image.Image.GetPropertyItem(LoopCount).Value, 0)
                    : 0;

                // Get the times stored in the gif. Default to 0 if not found.
                if (Array.IndexOf(this.image.Image.PropertyIdList, FrameDelay) != -1)
                {
                    this.times = this.image.Image.GetPropertyItem(FrameDelay).Value;
                }
            }
            else
            {
                this.FrameCount = 1;
            }
        }
Пример #2
0
        public BitmapUndo(IMAGE bmp)
        {
            undos = new Stack <BitmapChanges>();
            redos = new Stack <BitmapChanges>();
            bitmapUndoHistoryData = new Stack <Bitmap>();
            bitmapRedoHistoryData = new Stack <Bitmap>();

            CurrentBitmap = bmp;
        }
Пример #3
0
 public void Clear()
 {
     ClearHistory();
     if (CurrentBitmap != null)
     {
         CurrentBitmap.Dispose();
     }
     CurrentBitmap = null;
 }
Пример #4
0
        /// <summary>
        /// Dispose of the CurrentBitmap and replace it with the given bitmap.
        /// </summary>
        /// <param name="bmp">The new bitmap.</param>
        public void ReplaceBitmap(Bitmap bmp)
        {
            if (CurrentBitmap != null)
            {
                CurrentBitmap.Dispose();
            }

            CurrentBitmap = IMAGE.ProperCast(bmp, this.Format);
        }
Пример #5
0
        public ImageViewerForm(IMAGE img)
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            InitializeComponent();

            ivMain.Image    = img;
            ivMain.DrawMode = ImageDrawMode.Resizeable;
            ivMain.CenterCurrentImage();
        }
Пример #6
0
        /// <summary>
        /// Loads an iamge using the standard method.
        /// </summary>
        /// <param name="path">The path to the file.</param>
        protected void LoadSafe(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            Clear();
            this.Image = IMAGE.StandardLoad(path);
        }
Пример #7
0
 /// <summary>
 /// Loads a PNG image and returns it as a bitmap object.
 /// </summary>
 /// <param name="path">The path of the image.</param>
 /// <returns>A <see cref="Bitmap"/> object.</returns>
 public static Bitmap FromFileAsBitmap(string path)
 {
     try
     {
         return(IMAGE.StandardLoad(path));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "\r\nIn PNG.FromFileAsBitmap(string)");
     }
 }
Пример #8
0
        public static void ShowImage(string path)
        {
            using (IMAGE tempImage = ImageHelper.LoadImage(path))
            {
                if (tempImage == null)
                {
                    return;
                }

                using (ImageViewerForm viewer = new ImageViewerForm(tempImage))
                {
                    viewer.ShowDialog();
                }
            }
        }
Пример #9
0
        public static void ShowDisposeImage(IMAGE img)
        {
            if (img == null)
            {
                return;
            }

            /* using (Image tempImage = img)
             * {
             *   if (tempImage == null)
             *       return;*/

            using (ImageViewerForm viewer = new ImageViewerForm(img))
            {
                viewer.ShowDialog();
            }
            /* }*/
        }
Пример #10
0
        public static void ShowImage(IMAGE img)
        {
            if (img == null)
            {
                return;
            }

/*
 *          using (Image tempImage = img.CloneSafe())
 *          {
 *              if (tempImage == null)
 *                  return;
 */
            using (ImageViewerForm viewer = new ImageViewerForm(img))
            {
                viewer.ShowDialog();
            }
            //}
        }
Пример #11
0
 /// <summary>
 /// Sets the CurrentBitmap and does not dispose of the last bitmap.
 /// </summary>
 /// <param name="bmp">The new bitmap.</param>
 public void UpdateBitmapReferance(Bitmap bmp)
 {
     CurrentBitmap = IMAGE.ProperCast(bmp, this.Format);
 }
Пример #12
0
        public ClipForm(ClipOptions options, Image image)
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            InitializeComponent();
            SuspendLayout();

            Options = options;

            ClipName = Options.Name;

            _ChangeTracker = new BitmapUndo(IMAGE.ProperCast(image, InternalSettings.Default_Image_Format));

            _AspectRatio = image.Width / (double)image.Height;

            StartWindowSize = new Size(
                image.Width + (Options.BorderThickness << 1),
                image.Height + (Options.BorderThickness << 1));

            _ZoomControlSize = new Size(
                (int)Math.Round(StartWindowSize.Width * SettingsManager.ClipSettings.Zoom_Size_From_Percent),
                (int)Math.Round(StartWindowSize.Height * SettingsManager.ClipSettings.Zoom_Size_From_Percent));

            MinimumSize = StartWindowSize;
            MaximumSize = StartWindowSize;


            Bounds    = new Rectangle(options.Location, StartWindowSize);
            BackColor = Options.Color;

            zdbZoomedImageDisplay.Enabled            = false;
            zdbZoomedImageDisplay.borderColor        = SettingsManager.ClipSettings.Border_Color;
            zdbZoomedImageDisplay.replaceTransparent = SettingsManager.ClipSettings.Zoom_Color;
            if (SettingsManager.ClipSettings.Zoom_Size_From_Percent == 1f)
            {
                zdbZoomedImageDisplay.BorderThickness = 0;
            }
            else
            {
                zdbZoomedImageDisplay.BorderThickness = SettingsManager.ClipSettings.Zoom_Border_Thickness;
            }


            MouseDown  += MouseDown_Event;
            MouseUp    += MouseUp_Event;
            MouseMove  += MouseMove_Event;
            ResizeEnd  += ResizeEnded;
            KeyDown    += FormKeyDown;
            MouseWheel += ClipForm_MouseWheel;

            base.PreventHide = SettingsManager.ClipSettings.Never_Hide_Clips;
            base.RegisterEvents();

            #region context menu
            cmMain.Opening += CmMain_Opening;
            tsmiCopyToolStripMenuItem.Click            += CopyImage_Click;
            tsmiAllowResizeToolStripMenuItem.Click     += AllowResize_Click;
            tsmiOCRToolStripMenuItem.Click             += OCR_Click;
            tsmiSaveToolStripMenuItem.Click            += Save_Click;
            tsmiDestroyToolStripMenuItem.Click         += Destroy_Click;
            tsmiDestroyAllClipsToolStripMenuItem.Click += DestroyAllClips_Click;

            tsmiCopyDefaultContextMenuItem.Click    += CopyImage_Click;
            tsmiCopyZoomScaledContextMenuItem.Click += CopyScaledImage_Click;
            tsmiCopyZoomedImage.Click += CopyZoomedImage_Click;

            tsmiOpenInEditor.Click   += OpenInEditor_Click;
            tsmiInvertColor.Click    += InvertColor_Click;
            tsmiConvertToGray.Click  += ConvertToGray_Click;
            tsmiRotateLeft.Click     += RotateLeft_Click;
            tsmiRotateRight.Click    += RotateRight_Click;
            tsmiFlipHorizontal.Click += FlipHorizontal_Click;
            tsmiFlipVertical.Click   += FlipVertical_Click;

            if (_IsResizable)
            {
                tsmiAllowResizeToolStripMenuItem.Checked = true;
            }
            #endregion

            Text = ClipName;

            ResumeLayout(true);

            Show();

            UpdateTheme();

            TopMost = true;

            //for some reason if the clip is on a display that is scaled it makes it bigger than its supposed to be
            //so only allow it to be resized after 1000 ms
            Timer updateMaxSizeTimer = new Timer()
            {
                Interval = 1000
            };
            updateMaxSizeTimer.Tick += UpdateMaxSizeTimerTick_Event;
            updateMaxSizeTimer.Start();
        }