private void toolStripButton_paste_Click(object sender, EventArgs e) { string strError = ""; // 从剪贴板中取得图像对象 List <Image> images = ImageUtil.GetImagesFromClipboard(out strError); if (images == null) { strError = "。无法进行粘贴"; goto ERROR1; } Image image = images[0]; #if NO Image image = null; IDataObject obj1 = Clipboard.GetDataObject(); if (obj1.GetDataPresent(typeof(Bitmap))) { image = (Image)obj1.GetData(typeof(Bitmap)); } else if (obj1.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])obj1.GetData(DataFormats.FileDrop); try { image = Image.FromFile(files[0]); } catch (OutOfMemoryException) { strError = "当前 Windows 剪贴板中的第一个文件不是图像文件。无法进行粘贴"; goto ERROR1; } } else { strError = "当前 Windows 剪贴板中没有图形对象。无法进行粘贴"; goto ERROR1; } #endif if (this.tabControl_main.SelectedTab == this.tabPage_clip) { ImageUtil.SetImage(this.pictureBox_clip, image); // 2016/12/28 this.pictureBox_clip.InitialPoints(image); } if (this.tabControl_main.SelectedTab == this.tabPage_result) { this.Image = image; } return; ERROR1: MessageBox.Show(this, strError); }
// 注意,本函数以内,负责释放 frame private void ShowFrame(Bitmap frame) { try { int _frameWidth = frame.Width; int _frameHeight = frame.Height; if (pictureBox1.Width < _frameWidth) { pictureBox1.Width = _frameWidth; } if (pictureBox1.Height < _frameHeight) { pictureBox1.Height = _frameHeight; } // pictureBox1.Image = frame; // 2018/10/23 ImageUtil.SetImage(pictureBox1, frame); frame = null; #if NO if (_bFirstImageFilled == false) { if (this.FirstImageFilled != null) { this.FirstImageFilled(this, new EventArgs()); } _bFirstImageFilled = true; } #endif OnFirstImageFilled(false); #if NO if ((_iFrameCount % 20) == 0) { motionLevel = motionDetector.ProcessFrame(frame); // Debug.WriteLine("level=" + motionLevel.ToString()); if (motionLevel > 0.3F) { BeginInvoke(new Action(RefreshLastText)); } } _iFrameCount++; #endif } catch { } finally { if (frame != null) { frame.Dispose(); } } }
public void RotateImage(RotateFlipType flip_type) { Image image = this.pictureBox1.Image; image.RotateFlip(flip_type); pictureBox1.Width = image.Width; pictureBox1.Height = image.Height; ImageUtil.SetImage(pictureBox1, image); // 2016/12/28 }
void Shoot() { Image temp = this.qrRecognitionControl1.Image; // this.pictureBox_clip.Image = new Bitmap(temp); ImageUtil.SetImage(this.pictureBox_clip, new Bitmap(temp)); // 2012/12/28 this.pictureBox_clip.InitialPoints(temp); this.tabControl_main.SelectedTab = this.tabPage_clip; }
public void RotateImage(RotateFlipType flip_type) { RotatePoints(); Image image = this.Image; image.RotateFlip(flip_type); //this.Width = image.Width; //this.Height = image.Height; ImageUtil.SetImage(this, image); // 2016/12/28 this.Invalidate(); }
void Shoot() { Image temp = this.qrRecognitionControl1.Image; // 注意,此处 temp 可能为 null,会导致下一句抛出异常 // this.pictureBox_clip.Image = new Bitmap(temp); ImageUtil.SetImage(this.pictureBox_clip, new Bitmap(temp)); // 2012/12/28 if (this._pointsInitialized == false) { this.pictureBox_clip.InitialPoints(temp); _pointsInitialized = true; } this.tabControl_main.SelectedTab = this.tabPage_clip; }
private void toolStripButton_ratate_Click(object sender, EventArgs e) { if (this.tabControl_main.SelectedTab == this.tabPage_clip) { this.pictureBox_clip.RotateImage(RotateFlipType.Rotate90FlipNone); } if (this.tabControl_main.SelectedTab == this.tabPage_result) { Image image = this.pictureBox_result.Image; image.RotateFlip(RotateFlipType.Rotate90FlipNone); ImageUtil.SetImage(this.pictureBox_result, image); // 2016/12/28 _resultRotateAngle += 90; if (_resultRotateAngle == 360) { _resultRotateAngle = 0; } } }