开发者

Float array to Image

开发者 https://www.devze.com 2023-02-17 21:25 出处:网络
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)

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

0

精彩评论

暂无评论...
验证码 换一张
取 消