示例#1
0
        public static string Text(this ImagingMode imagingMode, string number = "", Image image = null, float scale = 1)
        {
            switch (imagingMode)
            {
            case ImagingMode.None:
                if (image == null)
                {
                    return(string.Format("Stamp Number = {0} · Scale = {1}%", number, (int)(100 * scale)));
                }
                else
                {
                    return(string.Format("Stamp Number = {0} ({1}×{2}) · Scale = {3}%", number, image.Width, image.Height, (int)(100 * scale)));
                }

            case ImagingMode.Rotate:
                return("Rotate Image");

            case ImagingMode.Crop:
                return("Crop Image");

            case ImagingMode.Recolor:
                return("Adjust Image Color");

            case ImagingMode.Sharpen:
                return("Sharpen Image");

            case ImagingMode.Brighten:
                return("Brighten Image");

            case ImagingMode.Blacken:
                return("Blackening Background");

            case ImagingMode.Measure:
                return("Measuring Stamp");

            case ImagingMode.Resize:
                return("Resize Image");

            case ImagingMode.Select:
                return("Select Vignette");

            case ImagingMode.Thumbnail:
                return("Create Thumbnail Image");

            default:
                throw new ArgumentOutOfRangeException("imagingMode");
            }
        }
示例#2
0
        private void updateOverlay(string s, Args arg)
        {
            #region Create mask overlay and add display_pbx

            ImagingMode imagingMode = IVLVariables.ivl_Camera.camPropsHelper.ImagingMode;
            if (imagingMode == ImagingMode.Posterior_45 || imagingMode == ImagingMode.Posterior_Prime || imagingMode == ImagingMode.FFA_Plus || imagingMode == ImagingMode.FFAColor)// if live mask true and posterior is enabled
            {
                if (Convert.ToBoolean(IVLVariables.CurrentSettings.PostProcessingSettings.MaskSettings._ApplyLiveMask.val))
                {
                    //maskOverlay_Pbx =new INTUSOFT.Custom.Controls.PictureBoxExtended();
                    maskOverlay_Pbx.Visible = true;

                    maskOverlay_Pbx.Dock      = DockStyle.Fill;
                    maskOverlay_Pbx.Parent    = display_pbx;
                    maskOverlay_Pbx.BackColor = Color.Transparent;
                    tempBm = new Bitmap(Convert.ToInt32(IVLVariables.CurrentSettings.CameraSettings._ImageWidth.val) - 2 * Convert.ToInt32(IVLVariables.CurrentSettings.CameraSettings._ImageROIX.val), Convert.ToInt32(IVLVariables.CurrentSettings.CameraSettings._ImageHeight.val) - 2 * Convert.ToInt32(IVLVariables.CurrentSettings.CameraSettings._ImageROIY.val), PixelFormat.Format24bppRgb);
                    Graphics g = Graphics.FromImage(tempBm);
                    g.FillEllipse(Brushes.White, new Rectangle(Convert.ToInt32(IVLVariables.CurrentSettings.CameraSettings._ImageOpticalCentreX.val) - Convert.ToInt32(IVLVariables.CurrentSettings.PostProcessingSettings.MaskSettings.LiveMaskWidth.val) / 2, Convert.ToInt32(IVLVariables.CurrentSettings.CameraSettings._ImageOpticalCentreY.val) - Convert.ToInt32(IVLVariables.CurrentSettings.PostProcessingSettings.MaskSettings.LiveMaskHeight.val) / 2, Convert.ToInt32(IVLVariables.CurrentSettings.PostProcessingSettings.MaskSettings.LiveMaskWidth.val), Convert.ToInt32(IVLVariables.CurrentSettings.PostProcessingSettings.MaskSettings.LiveMaskHeight.val)));
                    g.Dispose();
                    tempBm.MakeTransparent(Color.White);
                    maskOverlay_Pbx.Image = tempBm;
                }
                else
                {
                    maskOverlay_Pbx.Visible = false;
                    //if(this.Controls.Contains(maskOverlay_pbx))
                    //    this.Controls.Remove(maskOverlay_pbx);
                }
            }
            else
            {
                maskOverlay_Pbx.Visible = false;

                //if (this.Controls.Contains(maskOverlay_pbx))
                //    this.Controls.Remove(maskOverlay_pbx);
                // maskOverlay_pbx.Visible = false;
            }
            #endregion
        }
示例#3
0
        private void SetMode(ImagingMode mode)
        {
            this.mode = mode;

            labelMode.Text = this.mode.Text(scale: this.scale);

            panelButtons.Visible = false;
            panelImaging.Visible = true;
            panelRecolor.Visible = false;

            pTrial.Visible = true;
            pImage.Visible = false;
            pThumb.Visible = false;
            pColor.Visible = false;
            pPrint.Visible = false;

            pTrial.Image  = new Bitmap(pImage.Image);
            pTrial.Cursor = Cursors.Default;

            angle.Visible      = false;
            sharpness.Visible  = false;
            brightness.Visible = false;
            blacken.Visible    = false;
            measure.Visible    = false;
            resize.Visible     = false;

            this.isSelecting = false;

            switch (this.mode)
            {
            case ImagingMode.Rotate:
                angle.Value   = 0.0M;
                angle.Visible = true;
                break;

            case ImagingMode.Sharpen:
                sharpness.Value   = 0;
                sharpness.Visible = true;
                break;

            case ImagingMode.Brighten:
                brightness.Value   = 0;
                brightness.Visible = true;
                break;

            case ImagingMode.Blacken:
                blacken.Value   = 0;
                blacken.Visible = true;
                break;

            case ImagingMode.Measure:
                measure.Tag     = false;
                measure.Value   = 64;
                measure.Tag     = true;
                measure.Visible = true;
                Measure((byte)measure.Value, this.stamp.Perforation);
                break;

            case ImagingMode.Resize:
                resize.Value   = 100;
                resize.Visible = true;
                break;

            case ImagingMode.Crop:
            case ImagingMode.Select:
                pTrial.Cursor    = Cursors.Cross;
                this.isSelecting = true;
                this.selection   = new Rectangle();
                if (this.mode == ImagingMode.Select)
                {
                    this.selectionBrush = new SolidBrush(Color.FromArgb(64, 0, 0, 0));
                }
                else
                {
                    this.selectionBrush = new SolidBrush(Color.FromArgb(192, 255, 255, 255));
                }
                break;

            case ImagingMode.Recolor:
                panelRecolor.Visible = true;
                RerunRecolor();
                break;
            }

            buttonAccept.Enabled = false;

            Repaint();

            this.Focus();

            if (mode == ImagingMode.Thumbnail)
            {
                AcceptOrReject(accepted: true);
            }
        }
示例#4
0
        private void AcceptOrReject(bool accepted)
        {
            if (accepted)
            {
                this.isChanged = true;

                if (this.mode != ImagingMode.Measure)
                {
                    buttonSave.Enabled = true;
                    buttonUndo.Enabled = true;
                }

                switch (this.mode)
                {
                case ImagingMode.Rotate:

                    this.baseSize.Width  = (int)((float)pTrial.Image.Width / pImage.Image.Width * this.baseSize.Width);
                    this.baseSize.Height = (int)((float)pTrial.Image.Height / pImage.Image.Height * this.baseSize.Height);

                    pImage.Image.Dispose();
                    pImage.Image = new Bitmap(pTrial.Image);
                    pImage.Image.SaveAsJpeg(cImage, 100);

                    ImageHelper.CreateThumbnail(cImage, cThumb, stamp.Width, stamp.Height);
                    pThumb.LoadImageAndUnlock(cThumb);

                    break;

                case ImagingMode.Crop:

                    pImage.Image.Dispose();
                    pImage.Image = pTrial.Image.GetSelection(this.selection, convertToGrayscale: false);
                    pImage.Image.SaveAsJpeg(cImage, 100);

                    ImageHelper.CreateThumbnail(cImage, cThumb, stamp.Width, stamp.Height);
                    pThumb.LoadImageAndUnlock(cThumb);

                    break;

                case ImagingMode.Recolor:

                    pImage.Image = pImage.Image.Recolor((float)r.Value / 100, (float)g.Value / 100, (float)b.Value / 100);
                    pImage.Image.SaveAsJpeg(cImage, 100);

                    ImageHelper.CreateThumbnail(cImage, cThumb, stamp.Width, stamp.Height);
                    pThumb.LoadImageAndUnlock(cThumb);

                    break;

                case ImagingMode.Sharpen:

                    pImage.Image.Dispose();
                    pImage.Image = new Bitmap(pTrial.Image);
                    pImage.Image.SaveAsJpeg(cImage, 100);

                    ImageHelper.CreateThumbnail(cImage, cThumb, stamp.Width, stamp.Height);
                    pThumb.LoadImageAndUnlock(cThumb);

                    if (File.Exists(this.color))
                    {
                        pColor.Image = pColor.Image.Sharpen((float)sharpness.Value / 100);
                        pColor.Image.SaveAsJpeg(cColor, 100);
                    }

                    if (File.Exists(this.print))
                    {
                        pPrint.Image = pPrint.Image.Sharpen((float)sharpness.Value / 100);
                        pPrint.Image.SaveAsJpeg(cPrint, 100);
                    }

                    break;

                case ImagingMode.Brighten:

                    pImage.Image.Dispose();
                    pImage.Image = new Bitmap(pTrial.Image);
                    pImage.Image.SaveAsJpeg(cImage, 100);

                    ImageHelper.CreateThumbnail(cImage, cThumb, stamp.Width, stamp.Height);
                    pThumb.LoadImageAndUnlock(cThumb);

                    if (File.Exists(this.color))
                    {
                        pColor.Image = pColor.Image.Brighten((float)brightness.Value / 100);
                        pColor.Image.SaveAsJpeg(cColor, 100);
                    }

                    if (File.Exists(this.print))
                    {
                        pPrint.Image = pPrint.Image.Brighten((float)brightness.Value / 100);
                        pPrint.Image.SaveAsJpeg(cPrint, 100);
                    }

                    break;

                case ImagingMode.Blacken:

                    pImage.Image = pImage.Image.Blacken((byte)blacken.Value);
                    pImage.Image.SaveAsJpeg(cImage, 100);

                    ImageHelper.CreateThumbnail(cImage, cThumb, stamp.Width, stamp.Height);
                    pThumb.LoadImageAndUnlock(cThumb);

                    break;

                case ImagingMode.Measure:
                    break;

                case ImagingMode.Resize:

                    pImage.Image.Dispose();
                    pImage.Image = new Bitmap(pTrial.Image);
                    pImage.Image.SaveAsJpeg(cImage, 100);

                    break;

                case ImagingMode.Select:

                    pColor.Image.Dispose();
                    pColor.Image = pTrial.Image.GetSelection(this.selection, convertToGrayscale: false);
                    pColor.Image.SaveAsJpeg(cColor, 100);
                    pColor.LoadImageAndUnlock(cColor);

                    pPrint.Image.Dispose();
                    pPrint.Image = pTrial.Image.GetSelection(this.selection, convertToGrayscale: true);
                    pPrint.Image.SaveAsJpeg(cPrint, 100);
                    pPrint.LoadImageAndUnlock(cPrint);

                    break;

                case ImagingMode.Thumbnail:

                    ImageHelper.CreateThumbnail(cImage, cThumb, stamp.Width, stamp.Height);
                    pThumb.LoadImageAndUnlock(cThumb);

                    break;
                }
            }

            this.mode = ImagingMode.None;

            labelMode.Text = this.mode.Text(this.stamp.Number, pImage.Image, this.scale);

            panelButtons.Visible = true;
            panelImaging.Visible = false;
            panelRecolor.Visible = false;

            pTrial.Visible = false;
            pImage.Visible = true;
            pThumb.Visible = true;
            pColor.Visible = true;
            pPrint.Visible = true;

            Repaint();
        }
示例#5
0
        public void SetImage(Design series, string stampNumber, string folder, string country, string section)
        {
            this.series  = series;
            this.folder  = folder;
            this.country = country;
            this.section = section;

            this.stamp = series.GetStampFromSeries(stampNumber);

            string path = string.Format("{0}\\{1}\\{2}", folder, country, section);

            this.thumb = string.Format("{0}\\{1}.jpg", path, stamp.Number);
            this.image = string.Format("{0}\\image\\{1}.jpg", path, stamp.Number);
            this.color = string.Format("{0}\\xlcolor\\{1}.jpg", path, stamp.Number);
            this.print = string.Format("{0}\\xlprint\\{1}.jpg", path, stamp.Number);

            if (File.Exists(cThumb))
            {
                File.Delete(cThumb);
            }
            if (File.Exists(cImage))
            {
                File.Delete(cImage);
            }
            if (File.Exists(cColor))
            {
                File.Delete(cColor);
            }
            if (File.Exists(cPrint))
            {
                File.Delete(cPrint);
            }

            if (File.Exists(this.thumb))
            {
                File.Copy(this.thumb, cThumb, overwrite: true);
            }
            if (File.Exists(this.image))
            {
                File.Copy(this.image, cImage, overwrite: true);
            }
            if (File.Exists(this.color))
            {
                File.Copy(this.color, cColor, overwrite: true);
            }
            if (File.Exists(this.print))
            {
                File.Copy(this.print, cPrint, overwrite: true);
            }

            pImage.LoadImageAndUnlock(cImage);
            pThumb.LoadImageAndUnlock(cThumb);
            pColor.LoadImageAndUnlock(cColor);
            pPrint.LoadImageAndUnlock(cPrint);
            pTrial.LoadImageAndUnlock(cTrial);

            this.baseSize = GetBaseSize(path, pImage.Image.Width, pImage.Image.Height);

            buttonPrevious.Enabled = this.series.FindIndex(s => s.Number == this.stamp.Number) > 0;
            buttonNext.Enabled     = this.series.FindIndex(s => s.Number == this.stamp.Number) < this.series.Count() - 1;

            buttonRotate.Enabled    = File.Exists(cImage);
            buttonCrop.Enabled      = buttonRotate.Enabled;
            buttonRecolor.Enabled   = buttonRotate.Enabled;
            buttonBrighten.Enabled  = buttonRotate.Enabled;
            buttonBlacken.Enabled   = buttonRotate.Enabled;
            buttonMeasure.Enabled   = !string.IsNullOrEmpty(this.stamp.Perforation);
            buttonResize.Enabled    = buttonRotate.Enabled;
            buttonSelect.Enabled    = buttonRotate.Enabled;
            buttonThumbnail.Enabled = buttonRotate.Enabled;

            buttonSave.Enabled = false;
            buttonUndo.Enabled = false;

            panelButtons.Visible = true;
            panelImaging.Visible = false;
            panelRecolor.Visible = false;

            this.CancelButton = buttonClose;
            this.AcceptButton = null;

            this.mode = ImagingMode.None;

            labelMode.Text = this.mode.Text(this.stamp.Number, pImage.Image, this.scale);

            Repaint();
        }