public static Get5To8BitInvertedGamma ( double gamma = DefaultGamma ) : IEnumerable |
||
gamma | double | |
리턴 | IEnumerable |
public static Color[,] BufferToPixels(byte[] buffer, double senseHatGamma) { var pixels = new Color[8, 8]; byte[] senseHatInverseGammaTable = GammaCalc.Get5To8BitInvertedGamma(senseHatGamma).ToArray(); int bufferIndex = 0; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { var r = senseHatInverseGammaTable[buffer[bufferIndex]]; var g = senseHatInverseGammaTable[buffer[bufferIndex + 8]]; var b = senseHatInverseGammaTable[buffer[bufferIndex + 16]]; bufferIndex++; pixels[x, y] = Color.FromArgb(255, r, g, b); } bufferIndex += 16; } return(pixels); }
public static Image BufferToImage(byte[] buffer, double senseHatGamma) { var image = new Image(8, 8); byte[] senseHatInverseGammaTable = GammaCalc.Get5To8BitInvertedGamma(senseHatGamma).ToArray(); int bufferIndex = 0; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { var r = senseHatInverseGammaTable[buffer[bufferIndex]]; var g = senseHatInverseGammaTable[buffer[bufferIndex + 8]]; var b = senseHatInverseGammaTable[buffer[bufferIndex + 16]]; bufferIndex++; image[x, y] = Color.FromArgb(255, r, g, b); } bufferIndex += 16; } return(image); }