Commit 1085af9b LN

打开图片报错修改

1 个父辈 43f333cc
......@@ -85,7 +85,7 @@
this.pictureBox1.Size = new System.Drawing.Size(451, 313);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
this.pictureBox1.TabStop = false;
//
// txtResult
//
......@@ -148,7 +148,7 @@
// btnClearLog
//
this.btnClearLog.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnClearLog.Location = new System.Drawing.Point(711, 49);
this.btnClearLog.Location = new System.Drawing.Point(675, 49);
this.btnClearLog.Name = "btnClearLog";
this.btnClearLog.Size = new System.Drawing.Size(116, 33);
this.btnClearLog.TabIndex = 12;
......@@ -283,7 +283,7 @@
this.chbUseParam.Checked = true;
this.chbUseParam.CheckState = System.Windows.Forms.CheckState.Checked;
this.chbUseParam.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbUseParam.Location = new System.Drawing.Point(711, 16);
this.chbUseParam.Location = new System.Drawing.Point(675, 16);
this.chbUseParam.Name = "chbUseParam";
this.chbUseParam.Size = new System.Drawing.Size(75, 21);
this.chbUseParam.TabIndex = 26;
......@@ -327,7 +327,7 @@
this.chbZxing.Checked = true;
this.chbZxing.CheckState = System.Windows.Forms.CheckState.Checked;
this.chbZxing.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbZxing.Location = new System.Drawing.Point(792, 16);
this.chbZxing.Location = new System.Drawing.Point(765, 16);
this.chbZxing.Name = "chbZxing";
this.chbZxing.Size = new System.Drawing.Size(103, 21);
this.chbZxing.TabIndex = 31;
......
......@@ -146,11 +146,12 @@ namespace CodeLibrary
Image img = (Image)Image.FromFile(filename).Clone();
pictureBox1.Image = img;
Bitmap bitmap = new Bitmap(filename);
HDCodeLearnHelper.DefaultBitmap = bitmap;
HDCodeLearnHelper.DefaultBitmap = bitmap;
HObject hoimg;
HDCodeHelper.Bitmap2HObjectBpp24(bitmap,out hoimg);
HOperatorSet.ReadImage(out hoimg, filename);
//HDCodeHelper.Bitmap2HObjectBpp24(bitmap, out hoimg);
HDCodeLearnHelper.DefaultImage = hoimg;
ShowImage(hoimg);
ShowImage(hoimg);
}
}
......@@ -226,6 +227,10 @@ namespace CodeLibrary
}
public void ShowImage(HObject ho_Image)
{
if (ho_Image == null)
{
return;
}
HTuple width, height;
HOperatorSet.GetImageSize(ho_Image, out width, out height);
......@@ -507,61 +512,7 @@ namespace CodeLibrary
//ScanTest();
ScanDemo(100);
});
}
private void ScanTest()
{
for (int index = 1; index <= 200; index++)
{
try
{
label5.Text = "扫码测试_" + index;
int name = (index % 3) + 1;
string filename = @"F:\test\" + name + ".hobj";
if (!File.Exists(filename))
{
continue;
}
ClearPicImg();
if (filename.EndsWith(".hobj"))
{
HObject hObject = null;
HOperatorSet.GenEmptyObj(out hObject);
hObject.ReadObject(filename);
if (hObject != null)
{
HDCodeLearnHelper.DefaultImage = hObject;
ShowImage(hObject);
}
else
{
MessageBox.Show("读取文件失败:" + filename);
}
}
else
{
//读取图片内容
Image img = (Image)Image.FromFile(filename).Clone();
pictureBox1.Image = img;
Bitmap bitmap = new Bitmap(pictureBox1.Image);
HObject hoimg;
HDCodeHelper.Bitmap2HObjectBpp24(bitmap, out hoimg);
HDCodeLearnHelper.DefaultImage = hoimg;
ShowImage(hoimg);
}
btnDCode_Click(null, null);
Thread.Sleep(100);
}
catch (Exception ex)
{
HDLogUtil.error("ScanTest[" + index + "]出错:" + ex.ToString());
}
}
this.Enabled = true;
this.Cursor = Cursors.Default;
}
}
private void ScanDemo(int whileCount = 1)
{
......@@ -645,5 +596,6 @@ namespace CodeLibrary
string text = cmbCamera.Text;
Clipboard.SetDataObject(text);
}
}
}
......@@ -258,6 +258,7 @@ namespace CodeLibrary
HDLogUtil.error("将BitMap转换为HObject对象出错:" + ex.ToString());
ho_Image = null;
}
ho_Image = null;
return false ;
}
public static void HObject2Bpp8(HObject image, out Bitmap res)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!