using System;
namespace VideoStatusInspectorCSLib
{
///
/// 数据区用指针表示的图像
///
public class IntptrRawImage
{
private IntPtr _dataPointer;
private int _width;
private int _height;
private readonly int _bytesPerPixel = 0;
private readonly EnumColorType _colorType = EnumColorType.Gray8;
///
/// 数据区首地址
///
public IntPtr DataPointer { get => _dataPointer; }
///
/// 图像宽度
///
public int Width { get => _width; }
///
/// 图像高度
///
public int Height { get => _height; }
///
/// 一个像素用几个Byte来表示
/// 如:8位灰度图,则BytesPerPixel=1,24位RGB图像,则BytesPerPixel=3
///
public int BytesPerPixel { get => _bytesPerPixel; }
///
/// 图像的色彩类型
///
public EnumColorType ColorType { get => _colorType; }
///
/// 构造函数
///
public IntptrRawImage(EnumColorType colorType = EnumColorType.Gray8)
{
_dataPointer = IntPtr.Zero;
_width = 0;
_height = 0;
_colorType = colorType;
int bytesPerPixel = RawImage.GetBytesPerPixel(colorType);
_bytesPerPixel = bytesPerPixel;
}
///
/// 构造函数
///
///
///
///
///
public IntptrRawImage(IntPtr dataPointer, int width, int height, EnumColorType colorType)
{
_dataPointer = dataPointer;
_width = width;
_height = height;
_colorType = colorType;
int bytesPerPixel = RawImage.GetBytesPerPixel(colorType);
_bytesPerPixel = bytesPerPixel;
}
}
}