public static Get5BitGamma ( double gamma = DefaultGamma ) : IEnumerable |
||
gamma | double | |
리턴 | IEnumerable |
public static byte[] PixelsToBuffer(Color[,] pixels, double senseHatGamma) { byte[] buffer = new byte[8 * 8 * 3]; // (3 for R,G,B) byte[] senseHatGammaTable = GammaCalc.Get5BitGamma(senseHatGamma).ToArray(); int index = 0; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { Color color = pixels[x, y]; buffer[index] = senseHatGammaTable[color.R >> 3]; buffer[index + 8] = senseHatGammaTable[color.G >> 3]; buffer[index + 16] = senseHatGammaTable[color.B >> 3]; index++; } index += 16; // Step to the next row. } return(buffer); }
public static double Best5BitGammaMatch(byte[] wantedGammaTable, double start, double stop, double step) { var gammaValue = start; double bestMatchGammaValue = 0; int bestMatchGammaFailCount = int.MaxValue; do { byte[] myGamma = GammaCalc.Get5BitGamma(gammaValue).ToArray(); int failCount = 0; for (int i = 0; i < myGamma.Length; i++) { if (myGamma[i] != wantedGammaTable[i]) { failCount++; } } if (failCount < bestMatchGammaFailCount) { bestMatchGammaValue = gammaValue; bestMatchGammaFailCount = failCount; if (failCount == 0) { break; } } gammaValue += step; }while (gammaValue < stop); return(bestMatchGammaValue); }