日期:2014-05-18 浏览次数:21164 次
private void toolStripButton1_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "文本|*.jpg"; open.InitialDirectory = Directory.GetCurrentDirectory(); open.RestoreDirectory = true; if (open.ShowDialog()==DialogResult.OK) { backpicture = open.FileName; curimage = Image.FromFile(backpicture); } if (curimage != null) { pbitmap = new Bitmap(curimage); pictureBox1.Image = pbitmap; getbitmaparr(pbitmap); } }
Graphics recte = e.Graphics;//pictureBox1.CreateGraphics(); ivisible = newf.iwires; itemp = iarrbitmapindex * ivisible; ilocationy = (itemp / curimage.Width) * ivisible; //得到Y坐标 ilocationx = itemp % curimage.Width; //得到X坐标 Pen rectpen = new Pen(Color.Green, 2); Rectangle rect = new Rectangle(ilocationx, ilocationy, ivisible, ivisible); recte.DrawRectangle(rectpen, rect); rectpen.Dispose(); this.Invalidate(true);