///
赞
踩
/// <summary> /// 获得ICogImage图像格式 /// </summary> /// <param name="imagepath"></param> /// <returns></returns> private ICogImage GetImage(string imagepath) { if (!File.Exists(imagepath)) return null; CogImageFile ImageFile1 = new CogImageFile(); ICogImage Image; ImageFile1.Open(imagepath, CogImageFileModeConstants.Read); Image = ImageFile1[0]; ImageFile1.Close(); return Image; } /// <summary> /// 原图像保存 /// </summary> /// <param name="display"></param> /// <param name="path"></param> private void SaveOrignalImage(CogRecordDisplay display, string path) { try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string filename = "_" + DateTime.Now.ToString("HHmmssff") + "_" + ".bmp"; ICogImage orignalImage = display.Image; CogImageFile ImageFile = new CogImageFile(); ImageFile.Open(path + "\\" + filename, CogImageFileModeConstants.Write); ImageFile.Append(orignalImage); ImageFile.Close(); } catch (Exception ex) { Log.WriteTxt("保存图像出现错误:" + ex.Message); } } /// <summary> /// 保存图像截图 /// </summary> /// <param name="display"></param> /// <param name="path"></param> private void SaveScreenImage(CogRecordDisplay display, string path) //保存界面截图jpeg { try { // path = path + "\\" + "Camera-" + index.ToString(); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } string filename = "_" + DateTime.Now.ToString("HHmmssff") + "_" + ".jpg"; Bitmap bmp = display.CreateContentBitmap(CogDisplayContentBitmapConstants.Image) as Bitmap; // Bitmap bmp = display.Image.ToBitmap(); bmp.Save(path + "\\" + filename, System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception ex) { Log.WriteTxt("保存处理图像出现错误,信息为" + ex.Message); } } /// <summary> /// 将图像转换成CogImage8Grey /// </summary> /// <param name="imagepath">路径</param> /// <returns></returns> private CogImage8Grey GetSimulateImage(string imagepath) { if (File.Exists(imagepath)) return null; CogImageFile ImageFile1 = new CogImageFile(); CogImage8Grey Image; ImageFile1.Open(imagepath, CogImageFileModeConstants.Read); Image = (CogImage8Grey)ImageFile1[0]; ImageFile1.Close(); return Image; }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。