I have a list of colors and I am making a bitmap from it. Each color has a specific value for A, R, G and B. The problem is that when I save the bitmap and when I load it from the bitmap image file, all values for (A) Alpha are changed automatically to 255.
Here is the code for making the bitmap:
private Bitmap PaintImage(List<Color> colors, int width, int height)
{
Bitmap bitmap = new Bitmap(width, height);
int colorIndex = 0;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
bitmap.SetPixel(x, y, colors[colorIndex])
colorIndex += 1;
}
}
return bitmap;
}
Here is the code for saving the bitmap:
bitmap.Save(path, ImageFormat.Bmp);
Solution: I fixed the problem by using the PNG format.