Float array to Image
I have a float array representing a grayscale picture that I want to convert to an image in C#. How do I g开发者_开发百科o about doing so?
Bitmap newBitmap = new Bitmap(original.Width, original.Height);
for (int j = 0; j < original.Height; j++)
{
for (int i = 0; i < original.Width; i++)
{
Color newColor = Color.FromArgb((int)grayScale[i + j * original.Width], (int)grayScale[i + j * original.Width], (int)grayScale[i + j * original.Width]);
newBitmap.SetPixel(i, j, newColor);
}
}
Image img = (Image)newBitmap;
Microsoft forum for converting Example in codeproject
精彩评论