I currently have the following code in place to look through the pixels of a bitmap:
public struct Pixel
{
public byte Blue;
public byte Green;
public byte Red;
public byte Alpha;
public Pixel(byte blue, byte green, byte red, byte alpha)
{
Blue = blue;
Green = green;
Red = red;
Alpha = alpha;
}
}
public unsafe void Change(ref Bitmap inputBitmap)
{
Rectangle imageSize = new Rectangle(0, 0, inputBitmap.Width, inputBitmap.Height);
BitmapData imageData = inputBitmap.LockBits(imageSize, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
for (int indexY = 0; indexY < imageData.Height; indexY++)
{
byte* imageDataBytes = (byte*)imageData.Scan0 + (indexY * imageData.Stride);
for (int indexX = 0; indexX < imageData.Width; indexX++)
{
Pixel pixel = GetPixelColour(imageDataBytes, indexX);
}
}
inputBitmap.UnlockBits(imageData);
}
Once a pixel from the bytes is read, I want to be able to determine if the pixel is any shade of green. I'm having some problems figuring out what the math should be to determine the distance between a specific shade and green and the one being looked at.
Thank you in advance for the help.