Skip to content

Instantly share code, notes, and snippets.

@RickDB
Last active September 17, 2015 15:31
Show Gist options
  • Save RickDB/3e525393103c15569a81 to your computer and use it in GitHub Desktop.
Save RickDB/3e525393103c15569a81 to your computer and use it in GitHub Desktop.
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