I have captured a JPG image using a Webcam in C# and have stored it in a folder.
Now I want to convert it to an 8-bit PNG image.
I checked all over internet and Stack Overflow, but none of the proposed solutions work for me.
Here is what I am currently using:
Bitmap img = new Bitmap(imgPath);
Bitmap img8 = new Bitmap(imgW, imgH, PixelFormat.Format16bppRgb565);
for (int I = 0; I <= img.Width - 1; I++)
for (int J = 0; J <= img.Height - 1; J++)
img8.SetPixel(I, J, img.GetPixel(I, J));
However, this throws the following exception:
SetPixel is not allowed for indexed pixel images.