【发布时间】:2011-09-07 05:42:54
【问题描述】:
if (ImagesComparion1.ImageComparison(File1, file2, image_scan_text_rect) == true)
{
/* Logger.Write("File1 is >>>> " + combinedTemp);
// Logger.Write("File2 is >>>> " + fi.FullName);
Logger.Write("Last File is >>>> " + last_file);
Logger.Write("image_scan_text_rect values are >>>>> " + image_scan_text_rect.ToString());
Logger.Write("ImagesComparion1.ImageComparison(File1, file2, image_scan_text_rect) is now true");*/
if (pictureBox1.Image != null)
{
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
}
pictureBox1.Load(last_file);
File1.Dispose();
Properties.Resources.RadarImageClose.Dispose();
label18.Text = "The Radar Is Not Active Now";
label18.Visible = true;
if (paintDemoMode == true)
{
Bitmap bmp = new Bitmap(combinedTemp);
Bitmap bb = new Bitmap(bmp);
bmp.Dispose();
bmp = null;
if (pictureBox1.Image != null)
{
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
}
pictureBox1.Image = bb;
image_scan_text_rect = new Rectangle(25, 240, 341, 39);
float x = ((float)image_scan_text_rect.X / bb.Width) * (float)this.pictureBox1.Width;
//float y = ((float)Rect.Y / this.pictureBox1.ClientSize.Height) * (float)FirstImage.Height;
float y = ((float)image_scan_text_rect.Y / bb.Height) * (float)this.pictureBox1.Height;
//float newRight = ((float)Rect.Right / (float)pictureBox1.ClientSize.Width) * ((float)FirstImage.Width);
float newRight = ((float)image_scan_text_rect.Right / bb.Width) * (float)pictureBox1.Width;
//float newBottom = ((float)Rect.Bottom / (float)pictureBox1.ClientSize.Height) * ((float)FirstImage.Height);
float newBottom = ((float)image_scan_text_rect.Bottom / bb.Height) * (float)pictureBox1.Height;
rectToDrawOut = new RectangleF(x, y, newRight - x, newBottom - y);
pictureBox1.Image.Save(@"d:\testit.png", System.Drawing.Imaging.ImageFormat.Png);
}
return;
}
当我单击一个按钮并且paintDemoMode 为真时,它会将这个rectToDrawOut 显示为pictureBox1 上的矩形
现在我想将现在在pictureBox1中显示的图像保存到我的硬盘,包括矩形。
但它只是从没有矩形的图片框1 中获得的图像。我也尝试了 pictureBox1.Image.Save 我尝试了 bb.Save 但它再次没有保存矩形。这里有什么问题?
在 pictureBox1_Paint 事件中,如果需要,我会绘制矩形,这是代码:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
using (Pen pen = new Pen(Color.Red, 2))
{
if (paintDemoButtonSwitch == true)
{
e.Graphics.DrawRectangle(pen, rectToDrawOut.X, rectToDrawOut.Y, rectToDrawOut.Width, rectToDrawOut.Height);
}
}
}
感谢您的帮助。
【问题讨论】:
-
有没有机会修复缩进?