I am trying to do some assignment for my course and i am having issues with the SetPixel method on the Bitmap object.
// Retrieve the image.
image = new Bitmap(FileLocation);
SobelImage = image;
int x, y;
// Loop through the images pixels to reset color.
for (x = 0; x < image.Width; x++)
{
for (y = 0; y < image.Height; y++)
{
Console.WriteLine(String.Format("At {0} : {1}, Brightness : {2}", x, y, image.GetPixel(x, y).GetBrightness()));
Pixel pixel = new Pixel(image.GetPixel(x, y).GetBrightness());
SobelImage.SetPixel(x, y, Color.FromArgb(image.GetPixel(x, y).R, 0, 0));
}
}
Any help please, this is the exception : An unhandled exception of type 'System.InvalidOperationException' occurred in System.Drawing.dll
Additional information: SetPixel is not supported for images with indexed pixel formats.