1
0

RawImage.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. namespace UltrasoundImageDenoiseCSLib
  3. {
  4. /// <summary>
  5. /// 裸图像
  6. /// </summary>
  7. public class RawImage
  8. {
  9. /// <summary>
  10. /// 数据区,长度=Width*Height*Channel
  11. /// 一行数据的末尾没有填充值(补齐4字节),直接是所有点的各通道像素值
  12. /// </summary>
  13. public byte[] DataBuffer { get; set; }
  14. /// <summary>
  15. /// 图像宽度
  16. /// </summary>
  17. public int Width { get; set; }
  18. /// <summary>
  19. /// 图像高度
  20. /// </summary>
  21. public int Height { get; set; }
  22. /// <summary>
  23. /// 图像通道数
  24. /// </summary>
  25. public int Channel { get; set; }
  26. /// <summary>
  27. /// 构造函数
  28. /// </summary>
  29. public RawImage()
  30. {
  31. DataBuffer = null;
  32. Width = 0;
  33. Height = 0;
  34. Channel = 0;
  35. }
  36. /// <summary>
  37. /// 构造函数
  38. /// </summary>
  39. /// <param name="data"></param>
  40. /// <param name="width"></param>
  41. /// <param name="height"></param>
  42. /// <param name="channel"></param>
  43. public RawImage(byte[] data, int width, int height, int channel)
  44. {
  45. DataBuffer = data;
  46. Width = width;
  47. Height = height;
  48. Channel = channel;
  49. }
  50. /// <summary>
  51. /// 销毁
  52. /// C#中byte[]数组不需要专门手动dispose
  53. /// 这里保留Dispose是为了避免后面RawImage不再用byte[]时,不用再各处再增加dispose的代码
  54. /// </summary>
  55. public void Dispose()
  56. {
  57. if (DataBuffer != null)
  58. {
  59. Array.Clear(DataBuffer, 0, DataBuffer.Length);
  60. DataBuffer = null;
  61. }
  62. Width = 0;
  63. Height = 0;
  64. Channel = 0;
  65. }
  66. }
  67. }