Commit 66ddccc5 LN

bug修改

1 个父辈 039f60a0
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 2; this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
this.pictureBox1.DoubleClick += new System.EventHandler(this.pictureBox1_DoubleClick);
// //
// txtResult // txtResult
// //
......
...@@ -641,6 +641,58 @@ namespace CodeLibrary ...@@ -641,6 +641,58 @@ namespace CodeLibrary
Clipboard.SetDataObject(text); Clipboard.SetDataObject(text);
} }
private void pictureBox1_DoubleClick(object sender, EventArgs e)
{
if (pictureBox1.Image != null)
{
Bitmap map = new Bitmap(pictureBox1.Image);
SaveImageToFile(map);
}
else if (HDCodeLearnHelper.DefaultImage != null)
{
SaveImageToFile(HDCodeLearnHelper.DefaultImage);
}
}
private static string GetFName()
{
string date = DateTime.Now.ToString("yyyyMMdd-HHmmss") + "-" + DateTime.Now.Millisecond.ToString().PadLeft(4, '0');
string dire = @"D:\image\";
string iamgeName = date + ".bmp";
if (!Directory.Exists(dire))
{
Directory.CreateDirectory(dire);
}
return dire + iamgeName;
}
private static void SaveImageToFile( HalconDotNet.HObject bitmap)
{
try
{
string imgName = GetFName();
bitmap.WriteObject(imgName);
HDLogUtil.info( "保存图片到【" + imgName + "】成功");
MessageBox.Show(imgName);
}
catch (Exception ex)
{
HDLogUtil.error("保存 图片出错" + ex.ToString());
}
}
private static void SaveImageToFile(Bitmap bitmap)
{
try
{
string imgName = GetFName();
Bitmap bit = (Bitmap)bitmap.Clone();
bit.Save(imgName, ImageFormat.Bmp);
HDLogUtil.info("保存图片到【" + imgName + "】成功");
MessageBox.Show(imgName);
}
catch (Exception ex)
{
HDLogUtil.error("保存图片出错" + ex.ToString());
}
}
} }
} }
...@@ -72,9 +72,12 @@ namespace CodeLibrary ...@@ -72,9 +72,12 @@ namespace CodeLibrary
if (bmap.PixelFormat.Equals(PixelFormat.Format8bppIndexed)) if (bmap.PixelFormat.Equals(PixelFormat.Format8bppIndexed))
{ {
eyemImage.iChannels = 1; eyemImage.iChannels = 1;
}else }else if (bmap.PixelFormat.Equals(PixelFormat.Format24bppRgb))
{ {
eyemImage.iChannels = 3; eyemImage.iChannels = 3;
}else
{
eyemImage.iChannels = 4;
} }
eyemImage.iDepth = 0; eyemImage.iDepth = 0;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!