| | 1 | | // <copyright file="ColorQuantizerResult.cs" company="Jérémy Ansel"> |
| | 2 | | // Copyright (c) 2014-2019 Jérémy Ansel |
| | 3 | | // </copyright> |
| | 4 | | // <license> |
| | 5 | | // Licensed under the MIT license. See LICENSE.txt |
| | 6 | | // </license> |
| | 7 | |
|
| | 8 | | namespace JeremyAnsel.ColorQuant |
| | 9 | | { |
| | 10 | | using System; |
| | 11 | | using System.Diagnostics.CodeAnalysis; |
| | 12 | |
|
| | 13 | | /// <summary> |
| | 14 | | /// A result of color quantization. |
| | 15 | | /// </summary> |
| | 16 | | public sealed class ColorQuantizerResult |
| | 17 | | { |
| | 18 | | /// <summary> |
| | 19 | | /// Initializes a new instance of the <see cref="ColorQuantizerResult"/> class. |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="size">The size of the result.</param> |
| | 22 | | /// <param name="colorCount">The color count.</param> |
| 54 | 23 | | public ColorQuantizerResult(int size, int colorCount) |
| | 24 | | { |
| 54 | 25 | | if (size < 1) |
| | 26 | | { |
| 3 | 27 | | throw new ArgumentOutOfRangeException(nameof(size)); |
| | 28 | | } |
| | 29 | |
|
| 51 | 30 | | if (colorCount < 1 || colorCount > 256) |
| | 31 | | { |
| 6 | 32 | | throw new ArgumentOutOfRangeException(nameof(colorCount)); |
| | 33 | | } |
| | 34 | |
|
| 45 | 35 | | this.Palette = new byte[colorCount * 4]; |
| 45 | 36 | | this.Bytes = new byte[size]; |
| 45 | 37 | | } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Gets the palette (XRGB or ARGB). |
| | 41 | | /// </summary> |
| | 42 | | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Reviewed")] |
| 49479 | 43 | | public byte[] Palette { get; private set; } |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// Gets the bytes. |
| | 47 | | /// </summary> |
| | 48 | | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Reviewed")] |
| 17004 | 49 | | public byte[] Bytes { get; private set; } |
| | 50 | | } |
| | 51 | | } |
| | 52 | |
|