坐标不匹配问题
我将尺寸模式更改为正常,并观察到坐标相同,但图像尺寸过大,因此显示部分。 所以使用缩放大小模式属性。
说大小为2825x3538的图像,并将图片框大小模式保持为“正常”,图像部分显示在图片框中。 所以我改变了图片框模式进行缩放(以适应系统屏幕分辨率)。 并在使用缩放模式将其与普通模式进行比较时调整匹配失败。
我怎样才能达到相同的坐标。
private void openToolStripMenuItem_Click(object sender, EventArgs e) {链接地址: http://www.djcxy.com/p/50329.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); } } }