private void buttonPhotoRect_Click(object sender, EventArgs e) { photoResized = signResized = false; buttonSave.Enabled = false; using (Crop fCrop = new Crop(Path.Combine(Path.GetTempPath(), "tmp.jpg"), iniFileName, "Regionphoto")) fCrop.ShowDialog(); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + iniFileName)) { IniInterface oIni = new IniInterface(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, iniFileName)); _photoRect = RectAndINI.ReadRectFromIni(oIni, "Regionphoto"); } using (var fs = new FileStream(Path.Combine(Path.GetTempPath(), "tmp.jpg"), FileMode.Open)) //File not block { var bmp = new Bitmap(fs); var sourceimg = (Bitmap)bmp.Clone(); //Photo _srcPhoto = new Bitmap(sourceimg).Clone(_photoRect, PixelFormat.Format24bppRgb); pictureBoxPhoto.Image = ImageComputation.ImageConvertions.ApplyRangeLevels(photodefaultlefttreshold, photodefaultrighttreshold, _srcPhoto); } this.Info("PhotoRect_Click", this.Messages("resizeImage")); }
private void buttonBarRect_Click(object sender, EventArgs e) { using (Crop fCrop = new Crop(Path.Combine(Path.GetTempPath(), "tmp.jpg"), iniFileName, "Regionbar")) fCrop.ShowDialog(); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + iniFileName)) { IniInterface oIni = new IniInterface(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, iniFileName)); _barRect = RectAndINI.ReadRectFromIni(oIni, "Regionbar"); } //BarCode using (var fs = new FileStream(Path.Combine(Path.GetTempPath(), "tmp.jpg"), FileMode.Open)) //File not block { var bmp = new Bitmap(fs); var sourceimg = (Bitmap)bmp.Clone(); string numb = ScanQRCode(_barRect, sourceimg); textBoxNumber.Text = (!String.IsNullOrWhiteSpace(numb)) ? numb : textBoxNumber.Text; if (String.IsNullOrWhiteSpace(numb)) { textBoxNumber.ReadOnly = checkBoxBarNumber.Checked = false; } } }
private void _scanner_ScanComplete(object sender, EventArgs e) { if (!checkBoxAuto.Checked) { using (Crop fCrop = new Crop(Path.Combine(Path.GetTempPath(), "tmp.jpg"), iniFileName, String.Empty)) fCrop.ShowDialog(); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + iniFileName)) { IniInterface oIni = new IniInterface(AppDomain.CurrentDomain.BaseDirectory + iniFileName); _signRect = RectAndINI.ReadRectFromIni(oIni, "Regionsign"); _photoRect = RectAndINI.ReadRectFromIni(oIni, "Regionphoto"); _barRect = RectAndINI.ReadRectFromIni(oIni, "Regionbar"); } checkBoxAuto.Checked = true; } photoResized = signResized = false; buttonSave.Enabled = false; buttonPhotoRect.Enabled = buttonSignatureRect.Enabled = buttonBarRect.Enabled = true; buttonEditSignature.Enabled = button3.Enabled = true; using (var fs = new FileStream(Path.Combine(Path.GetTempPath(), "tmp.jpg"), FileMode.Open)) //File not block { var bmp = new Bitmap(fs); var sourceimg = (Bitmap)bmp.Clone(); //Photo _srcPhoto = new Bitmap(sourceimg).Clone(_photoRect, PixelFormat.Format24bppRgb); pictureBoxPhoto.Image = ImageComputation.ImageConvertions.ApplyRangeLevels(photodefaultlefttreshold, photodefaultrighttreshold, _srcPhoto); this.Info("Successfuly get Photo"); //Signature _srcSign = ImageComputation.ImageConvertions.MakeGrayscale3(new Bitmap(sourceimg).Clone(_signRect, PixelFormat.Format24bppRgb)); pictureBoxSignature.Image = ImageComputation.ImageConvertions.ApplyRangeLevels(signdefaultlefttreshold, signdefaultrighttreshold, _srcSign); this.Info("Successfuly get Signature"); this.Info("scanner_ScanComplete", this.Messages("resizeImage")); //QRCode string numb = String.Empty; if (checkBoxBarNumber.Checked) { numb = ScanQRCode(_barRect, sourceimg); textBoxNumber.Text = (!String.IsNullOrWhiteSpace(numb)) ? numb : textBoxNumber.Text; this.Info("Successfuly get QRCode"); } if (String.IsNullOrWhiteSpace(numb)) { textBoxNumber.ReadOnly = checkBoxBarNumber.Checked = false; } } }
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"); } }