Пример #1
0
        private void fMain_Load(object sender, EventArgs e)
        {
            if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, iniFileName)))
            {
                IniInterface oIni = new IniInterface(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, iniFileName));
                string       val  = oIni.ReadValue("Scan", "color", "Color");
                checkBoxAuto.Checked      = (oIni.ReadValue("Scan", "auto", "true") == "true") ? true : false;
                checkBoxBarNumber.Checked = (oIni.ReadValue("Scan", "barNumber", "true") == "true") ? true : false;

                textBoxNumber.ReadOnly =
                    checkBoxBarNumber.Checked;


                _color = val == "Color" ? ScanColor.Color : (
                    val == "BlackWhite" ? ScanColor.BlackWhite :
                    ScanColor.Gray);
                if (!int.TryParse(oIni.ReadValue("Scan", "dpi", "300"), out _dpi))
                {
                    _dpi = 300;
                }

                _path            = oIni.ReadValue("Save", "path", AppDomain.CurrentDomain.BaseDirectory);
                textBoxPath.Text = _path;
                _photoPrefix     = oIni.ReadValue("Save", "photoprefix", String.Empty);
                _signPrefix      = oIni.ReadValue("Save", "signprefix", String.Empty);
                _photoJP2Prefix  = oIni.ReadValue("Save", "photojp2prefix", String.Empty);
                _signJP2Prefix   = oIni.ReadValue("Save", "signjp2prefix", String.Empty);
                _photoSufix      = oIni.ReadValue("Save", "photosufix", "F");
                _signSufix       = oIni.ReadValue("Save", "signsufix", "P");
                _photoJP2Sufix   = oIni.ReadValue("Save", "photojp2sufix", "F2");
                _signJP2Sufix    = oIni.ReadValue("Save", "signjp2sufix", "P2");

                if (!int.TryParse(oIni.ReadValue("Save", "photomaxweight", "18000"), out _photoMaxWeight))
                {
                    _photoMaxWeight = 18000;
                }
                if (!int.TryParse(oIni.ReadValue("Save", "signmaxweight", "8000"), out _signMaxWeight))
                {
                    _signMaxWeight = 8000;
                }
                if (!int.TryParse(oIni.ReadValue("Save", "compressdpi", "300"), out _compressDPI))
                {
                    _compressDPI = 300;
                }

                if (!int.TryParse(oIni.ReadValue("Save", "photowidth", "283"), out photowidth))
                {
                    photowidth = 283;
                }
                if (!int.TryParse(oIni.ReadValue("Save", "photoheight", "364"), out photoheight))
                {
                    photoheight = 364;
                }
                if (!int.TryParse(oIni.ReadValue("Save", "signwidth", "283"), out signwidth))
                {
                    signwidth = 283;
                }
                if (!int.TryParse(oIni.ReadValue("Save", "signheight", "94"), out signheight))
                {
                    signheight = 94;
                }

                if (!int.TryParse(oIni.ReadValue("Save", "signdefaultlefttreshold", "125"), out signdefaultlefttreshold))
                {
                    signdefaultlefttreshold = 125;
                }
                if (!int.TryParse(oIni.ReadValue("Save", "signdefaultrighttreshold", "255"), out signdefaultrighttreshold))
                {
                    signdefaultrighttreshold = 255;
                }
                if (!int.TryParse(oIni.ReadValue("Save", "photodefaultlefttreshold", "0"), out photodefaultlefttreshold))
                {
                    photodefaultlefttreshold = 0;
                }
                if (!int.TryParse(oIni.ReadValue("Save", "photodefaultrighttreshold", "255"), out photodefaultrighttreshold))
                {
                    photodefaultrighttreshold = 255;
                }

                _deviceuuid = oIni.ReadValue("Scan", "deviceuuid", AppDomain.CurrentDomain.BaseDirectory);

                _signRect  = RectAndINI.ReadRectFromIni(oIni, "Regionsign");
                _photoRect = RectAndINI.ReadRectFromIni(oIni, "Regionphoto");
                _barRect   = RectAndINI.ReadRectFromIni(oIni, "Regionbar");
            }
        }
Пример #2
0
        private void Form_Load(object sender, EventArgs e)
        {
            _imageOut = SrcPicBox.Image = _image;

            var ratioX = (double)SrcPicBox.Width / _image.Width;
            var ratioY = (double)SrcPicBox.Height / _image.Height;

            ratio = Math.Min(ratioX, ratioY);

            // Compute the offset of the image to center it in the picture box
            var scaledWidth  = _image.Width * ratio;
            var scaledHeight = _image.Height * ratio;

            imageX = (int)((SrcPicBox.Width - scaledWidth) / 2);
            imageY = (int)((SrcPicBox.Height - scaledHeight) / 2);

            IniInterface oIni      = new IniInterface(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, iniFileName));
            var          phWidht   = Convert.ToInt32(oIni.ReadValue("Save", "photowidth"));
            var          phHeight  = Convert.ToInt32(oIni.ReadValue("Save", "photoheight"));
            var          sgnWidht  = Convert.ToInt32(oIni.ReadValue("Save", "signwidth"));
            var          sgnHeight = Convert.ToInt32(oIni.ReadValue("Save", "signheight"));

            double phCoef              = (double)phWidht / phHeight;
            double sgnCoef             = (double)sgnWidht / sgnHeight;
            var    initresholdleftkey  = "signdefaultlefttreshold";
            var    initresholdrightkey = "signdefaultrighttreshold";

            switch (iniKey.ToLower())
            {
            case "photo":
            {
                coef = phCoef;
                initresholdleftkey  = "photodefaultlefttreshold";
                initresholdrightkey = "photodefaultrighttreshold";
            }
            break;

            case "sign":
            {
                coef = sgnCoef;
                initresholdleftkey  = "signdefaultlefttreshold";
                initresholdrightkey = "signdefaultrighttreshold";
            }
            break;

            default:
            {
                coef = 1;
                initresholdleftkey  = "signdefaultlefttreshold";
                initresholdrightkey = "signdefaultrighttreshold";
            }
            break;
            }

            if (!int.TryParse(oIni.ReadValue("Save", initresholdleftkey, "0"), out defaultlefttreshold))
            {
                defaultlefttreshold = 125;
            }
            if (!int.TryParse(oIni.ReadValue("Save", initresholdrightkey, "255"), out defaultrighttreshold))
            {
                defaultrighttreshold = 255;
            }

            pictureBoxOut.Image = ImageComputation.ImageConvertions.ApplyRangeLevels(defaultlefttreshold, defaultrighttreshold, _imageOut);
            histogram.DrawHistogram(GetHistogram((Bitmap)_imageOut));
            rangeLevels.Value = new DevExpress.XtraEditors.Repository.TrackBarRange(defaultlefttreshold, defaultrighttreshold);
        }