Last active
September 17, 2015 15:31
-
-
Save RickDB/3e525393103c15569a81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ChangeImage(byte[] pixeldata, byte[] bmiInfoHeader) | |
{ | |
if (!IsConnected()) | |
{ | |
return; | |
} | |
int i = 0; | |
while (i <= (pixeldata.GetLength(0) - 2)) | |
{ | |
// Change color profile to 6-235 | |
// RED | |
if (pixeldata[i] <= 16) | |
{ | |
pixeldata[i] = 0; | |
} | |
else if (pixeldata[i] >= 235) | |
{ | |
pixeldata[i] = 255; | |
} | |
// GREEN | |
if (pixeldata[i + 1] <= 16) | |
{ | |
pixeldata[i + 1] = 0; | |
} | |
else if (pixeldata[i + 1] >= 235) | |
{ | |
pixeldata[i + 1] = 255; | |
} | |
// BLUE | |
if (pixeldata[i + 2] <= 16) | |
{ | |
pixeldata[i + 2] = 0; | |
} | |
else if (pixeldata[i + 2] >= 235) | |
{ | |
pixeldata[i + 2] = 255; | |
} | |
i += 4; | |
} | |
SetPixelData(bmiInfoHeader, pixeldata); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment