Commit 4a02e704 刘韬

1

1 个父辈 a86e36db
此文件类型无法预览
......@@ -8,6 +8,8 @@ using System.Runtime.InteropServices;
using MvCamCtrl.NET;
using CameraVisionLib.Model;
using System.Runtime.ExceptionServices;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace Asa.HIK
{
......@@ -487,20 +489,21 @@ namespace Asa.HIK
if (enDstPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8)
{
_image = new Bitmap(stFrameInfo.nWidth, stFrameInfo.nHeight, stFrameInfo.nWidth * 1, PixelFormat.Format8bppIndexed, pImage);
var t_image = new Bitmap(stFrameInfo.nWidth, stFrameInfo.nHeight, stFrameInfo.nWidth * 1, PixelFormat.Format8bppIndexed, pImage);
_format = PixelFormat.Format8bppIndexed;
_handle = pImage;
ColorPalette cp = _image.Palette;
ColorPalette cp = t_image.Palette;
for (int i = 0; i < 256; i++)
cp.Entries[i] = Color.FromArgb(i, i, i);
_image.Palette = cp;
int picSize = _image.Width * _image.Height;
_buffer = new byte[picSize];
Array.Copy(buffArr, _buffer, picSize);
t_image.Palette = cp;
//int picSize = _image.Width * _image.Height;
//_buffer = new byte[picSize];
// Array.Copy(buffArr, _buffer, picSize);
_image = DeepClone(t_image);
t_image.Dispose();
//Rectangle rect = new Rectangle(0, 0, Image.Width, Image.Height);
//BitmapData bmpData = Image.LockBits(rect, ImageLockMode.ReadWrite, Image.PixelFormat);
//IntPtr iPtr = bmpData.Scan0;
......@@ -520,16 +523,39 @@ namespace Asa.HIK
buffArr[i * stFrameInfo.nWidth * 3 + j * 3 + 2] = chRed;
}
}
_image = new Bitmap(stFrameInfo.nWidth, stFrameInfo.nHeight, stFrameInfo.nWidth * 3, PixelFormat.Format24bppRgb, pImage);
var t_image = new Bitmap(stFrameInfo.nWidth, stFrameInfo.nHeight, stFrameInfo.nWidth * 3, PixelFormat.Format24bppRgb, pImage);
_format = PixelFormat.Format24bppRgb;
_handle = pImage;
int picSize = _image.Width * _image.Height * 3;
int picSize = t_image.Width * t_image.Height * 3;
_buffer = new byte[picSize];
Array.Copy(buffArr, _buffer, picSize);
_image = DeepClone(t_image);
t_image.Dispose();
}
}
public static T DeepClone<T>(T _object)
{
try
{
T dstobject;
using (MemoryStream mStream = new MemoryStream())
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(mStream, _object);
mStream.Seek(0, SeekOrigin.Begin);//指定当前流的位置为流的开头。
dstobject = (T)bf.Deserialize(mStream);
mStream.Close();
}
return dstobject;
}
catch (Exception e)
{
Common.log.Error("DeepClone" + e.ToString());
return default;
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!