| | 1 | | using System; |
| | 2 | | using ReFlex.Core.Common.Util; |
| | 3 | |
|
| | 4 | | namespace ReFlex.Core.Common.Components |
| | 5 | | { |
| | 6 | | public class ImageByteArray |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Initializes all class members |
| | 10 | | /// </summary> |
| | 11 | | /// <param name="imageData">byte data containing the image. Must not be null and has to be of sufficient size (w |
| | 12 | | /// <param name="width">the width of the image in pixel</param> |
| | 13 | | /// <param name="height">the height od the image in pixel</param> |
| | 14 | | /// <param name="bytesPerChannel">the number of bytes used per color channel</param> |
| | 15 | | /// <param name="numChannels">the number of channels used</param> |
| | 16 | | /// <param name="format"><see cref="DepthImageFormat"/> for encoding / decoding</param> |
| | 17 | | /// <exception cref="NullReferenceException">if imageData is null</exception> |
| | 18 | | /// <exception cref="ArgumentException">if size of imageData is incorrect</exception> |
| 8 | 19 | | public ImageByteArray(byte[] imageData, |
| 8 | 20 | | int width, int height, |
| 8 | 21 | | uint bytesPerChannel, uint numChannels, |
| 8 | 22 | | DepthImageFormat format = DepthImageFormat.Rgb24bpp) |
| 8 | 23 | | { |
| 8 | 24 | | if (imageData == null) |
| 1 | 25 | | throw new NullReferenceException($"Provided value for {nameof(imageData)} must not be null."); |
| | 26 | |
|
| 7 | 27 | | if (imageData.Length != width * height * bytesPerChannel * numChannels) |
| 5 | 28 | | throw new ArgumentException( |
| 5 | 29 | | $"Wrong size of {nameof(imageData)}: provided size of {imageData.Length} does not meet the required |
| | 30 | |
|
| 2 | 31 | | ImageData = imageData; |
| 2 | 32 | | BytesPerChannel = bytesPerChannel; |
| 2 | 33 | | NumChannels = numChannels; |
| 2 | 34 | | Width = width; |
| 2 | 35 | | Height = height; |
| 2 | 36 | | Format = format; |
| 2 | 37 | | } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Array containing the image data as bytes. Array is assigned in constructor and has the size <see cref="W |
| | 41 | | /// <see cref="Height" /> x <see cref="BytesPerChannel" />. |
| | 42 | | /// </summary> |
| 3 | 43 | | public byte[] ImageData { get; } |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// Number of bytes used for each color channell |
| | 47 | | /// </summary> |
| 2 | 48 | | public uint BytesPerChannel { get; } |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Number of color channels |
| | 52 | | /// </summary> |
| 2 | 53 | | public uint NumChannels { get; } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Width of the image in Pixel |
| | 57 | | /// </summary> |
| 2 | 58 | | public int Width { get; } |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// Height of the image in Pixel |
| | 62 | | /// </summary> |
| 2 | 63 | | public int Height { get; } |
| | 64 | |
|
| | 65 | | /// <summary> |
| | 66 | | /// <see cref="DepthImageFormat"/> for encoding / decoding |
| | 67 | | /// </summary> |
| 2 | 68 | | public DepthImageFormat Format { get; } |
| | 69 | | } |
| | 70 | | } |