|
- using OpenCvSharp.Flann;
- using Org.BouncyCastle.Utilities.Collections;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
-
- namespace MaiMuAOI.SysUI.DefectPicShow
- {
- public partial class PhotoFrm : Form
- {
- private List<Bitmap> lstBmp = new List<Bitmap>();
- private int picIndex = 0;
-
- public PhotoFrm(List<Bitmap> list)
- {
- InitializeComponent();
- UIStyle.SetUIStyle(this);
- this.uiTitel1.FatherForm = this;
-
- lstBmp = list;
- }
-
- private void PhotoFrm_Shown(object sender, EventArgs e)
- {
- this.reloadPic(picIndex);
-
- }
- private void reloadPic(int index)
- {
- try
- {
- logsts.Text = $"第 {picIndex + 1}/{lstBmp.Count} 张";
- tsbtnPre.Enabled = (picIndex > 0);
- tsbtnNext.Enabled = (picIndex < lstBmp.Count - 1);
-
- Bitmap currBmp = (Bitmap)lstBmp[index];
- OpenCvSharp.Mat mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(currBmp);//用bitmap转换为mat
- this.imageBox1.RefreshWindow(mat);
-
- //
- this.tsbtnPre.Enabled = (index > 0);
- this.tsbtnNext.Enabled = (index < lstBmp.Count - 1);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
- private void tsbtnExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
-
- private void tsbtnPre_Click(object sender, EventArgs e)
- {
- this.reloadPic(--picIndex);
- }
-
- private void tsbtnNext_Click(object sender, EventArgs e)
- {
- this.reloadPic(++picIndex);
- }
- }
- }
|