| | | 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 | | /// The maximum color count. |
| | | 20 | | /// </summary> |
| | | 21 | | public const int MaxColors = 256; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Initializes a new instance of the <see cref="ColorQuantizerResult"/> class. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <param name="size">The size of the result.</param> |
| | | 27 | | /// <param name="colorCount">The color count.</param> |
| | 54 | 28 | | public ColorQuantizerResult(int size, int colorCount) |
| | | 29 | | { |
| | 54 | 30 | | if (size < 1) |
| | | 31 | | { |
| | 2 | 32 | | throw new ArgumentOutOfRangeException(nameof(size)); |
| | | 33 | | } |
| | | 34 | | |
| | 52 | 35 | | if (colorCount < 1 || colorCount > 256) |
| | | 36 | | { |
| | 4 | 37 | | throw new ArgumentOutOfRangeException(nameof(colorCount)); |
| | | 38 | | } |
| | | 39 | | |
| | 48 | 40 | | this.Palette = new byte[colorCount * 4]; |
| | 48 | 41 | | this.Bytes = new byte[size]; |
| | 48 | 42 | | } |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Gets the palette (XRGB or ARGB). |
| | | 46 | | /// </summary> |
| | | 47 | | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Reviewed")] |
| | 1207998846 | 48 | | public byte[] Palette { get; private set; } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Gets the bytes. |
| | | 52 | | /// </summary> |
| | | 53 | | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Reviewed")] |
| | 603991148 | 54 | | public byte[] Bytes { get; private set; } |
| | | 55 | | } |
| | | 56 | | } |
| | | 57 | | |