Coordinate Mismatch Problem
I changed the Size mode to normal and observed that the coordinates are same but the Image size is too large so it display partially. so use zoom size mode property.
Say image with size 2825x3538 and keep the picture box size mode as Normal, the image shows partially in picture box. So i changed picture box mode to zoom (to fit the System screen resolution). and coordinate miss matched when compare it with Normal mode with zoom mode.
How can i achieve the same coordinates.
private void openToolStripMenuItem_Click(object sender, EventArgs e) {链接地址: http://www.djcxy.com/p/50330.htmlOpenFD.FileName = ""; OpenFD.Title = "open image"; OpenFD.InitialDirectory = "C"; OpenFD.Filter = "JPEG|*.jpg|Bmp|*.bmp|All Files|*.*.*"; if (OpenFD.ShowDialog() == DialogResult.OK) { file = OpenFD.FileName; image = Image.FromFile(file); pictureBox1.Image = image; svc = Screen.PrimaryScreen; pictureBox1.Width = svc.Bounds.Width; pictureBox1.Height = svc.Bounds.Height-100; mybitmap1 = new Bitmap (pictureBox1.Image); mybitmap1.SetResolution(300, 300); pictureBox1.Image = mybitmap1; } }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (mybitmap == null) { mybitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height); mybitmap.SetResolution(300, 300); } }
private void pictureBox1_Paint(object sender, PaintEventArgs e) {
using (g = Graphics.FromImage(mybitmap)) { using (Pen pen = new Pen(Color.Green, m)) { e.Graphics.DrawRectangle(pen, r); e.Graphics.DrawString(lab[c].ToString(), new Font(lab[c].ToString(), 8F), new SolidBrush(label1.ForeColor), r); } } }
上一篇: 使用System.Drawing.DrawRectangle绘制选择矩形来选择事物
下一篇: 坐标不匹配问题