|  |  | 1 |  | // <copyright file="Box.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 |  |     /// <summary> | 
|  |  | 11 |  |     /// A box color cube. | 
|  |  | 12 |  |     /// </summary> | 
|  |  | 13 |  |     internal sealed class Box | 
|  |  | 14 |  |     { | 
|  |  | 15 |  |         /// <summary> | 
|  |  | 16 |  |         /// The index bits. | 
|  |  | 17 |  |         /// </summary> | 
|  |  | 18 |  |         private const int IndexBits = 7; | 
|  |  | 19 |  |  | 
|  |  | 20 |  |         /// <summary> | 
|  |  | 21 |  |         /// Gets or sets the min red value, exclusive. | 
|  |  | 22 |  |         /// </summary> | 
|  |  | 23 |  |         public int R0; | 
|  |  | 24 |  |  | 
|  |  | 25 |  |         /// <summary> | 
|  |  | 26 |  |         /// Gets or sets the max red value, inclusive. | 
|  |  | 27 |  |         /// </summary> | 
|  |  | 28 |  |         public int R1; | 
|  |  | 29 |  |  | 
|  |  | 30 |  |         /// <summary> | 
|  |  | 31 |  |         /// Gets or sets the min green value, exclusive. | 
|  |  | 32 |  |         /// </summary> | 
|  |  | 33 |  |         public int G0; | 
|  |  | 34 |  |  | 
|  |  | 35 |  |         /// <summary> | 
|  |  | 36 |  |         /// Gets or sets the max green value, inclusive. | 
|  |  | 37 |  |         /// </summary> | 
|  |  | 38 |  |         public int G1; | 
|  |  | 39 |  |  | 
|  |  | 40 |  |         /// <summary> | 
|  |  | 41 |  |         /// Gets or sets the min blue value, exclusive. | 
|  |  | 42 |  |         /// </summary> | 
|  |  | 43 |  |         public int B0; | 
|  |  | 44 |  |  | 
|  |  | 45 |  |         /// <summary> | 
|  |  | 46 |  |         /// Gets or sets the max blue value, inclusive. | 
|  |  | 47 |  |         /// </summary> | 
|  |  | 48 |  |         public int B1; | 
|  |  | 49 |  |  | 
|  |  | 50 |  |         /// <summary> | 
|  |  | 51 |  |         /// Gets or sets the volume. | 
|  |  | 52 |  |         /// </summary> | 
|  |  | 53 |  |         public int Volume; | 
|  |  | 54 |  |  | 
|  |  | 55 |  |         public int Index111; | 
|  |  | 56 |  |         public int Index110; | 
|  |  | 57 |  |         public int Index101; | 
|  |  | 58 |  |         public int Index100; | 
|  |  | 59 |  |         public int Index011; | 
|  |  | 60 |  |         public int Index010; | 
|  |  | 61 |  |         public int Index001; | 
|  |  | 62 |  |         public int Index000; | 
|  |  | 63 |  |  | 
|  |  | 64 |  |         public void Update() | 
|  |  | 65 |  |         { | 
|  | 5104 | 66 |  |             Volume = (R1 - R0) * (G1 - G0) * (B1 - B0); | 
|  |  | 67 |  |  | 
|  | 5104 | 68 |  |             int r1 = (R1 << (IndexBits * 2)) + (R1 << (IndexBits + 1)) + R1; | 
|  | 5104 | 69 |  |             int r0 = (R0 << (IndexBits * 2)) + (R0 << (IndexBits + 1)) + R0; | 
|  | 5104 | 70 |  |             int g1 = (G1 << IndexBits) + G1; | 
|  | 5104 | 71 |  |             int g0 = (G0 << IndexBits) + G0; | 
|  | 5104 | 72 |  |             int b1 = B1; | 
|  | 5104 | 73 |  |             int b0 = B0; | 
|  |  | 74 |  |  | 
|  | 5104 | 75 |  |             Index111 = r1 + g1 + b1; | 
|  | 5104 | 76 |  |             Index110 = r1 + g1 + b0; | 
|  | 5104 | 77 |  |             Index101 = r1 + g0 + b1; | 
|  | 5104 | 78 |  |             Index100 = r1 + g0 + b0; | 
|  | 5104 | 79 |  |             Index011 = r0 + g1 + b1; | 
|  | 5104 | 80 |  |             Index010 = r0 + g1 + b0; | 
|  | 5104 | 81 |  |             Index001 = r0 + g0 + b1; | 
|  | 5104 | 82 |  |             Index000 = r0 + g0 + b0; | 
|  | 5104 | 83 |  |         } | 
|  |  | 84 |  |     } | 
|  |  | 85 |  | } | 
|  |  | 86 |  |  |