AForge.Imaging.Textures.TextureTools.ToBitmap C# (CSharp) Метод

ToBitmap() публичный статический Метод

Convert texture to grayscale bitmap.
public static ToBitmap ( float texture ) : Bitmap
texture float Texture to convert to bitmap.
Результат System.Drawing.Bitmap
        public static Bitmap ToBitmap( float[,] texture )
        {
            // get texture dimension
            int width  = texture.GetLength( 1 );
            int height = texture.GetLength( 0 );

            // create new grawscale image
            Bitmap dstImage = AForge.Imaging.Image.CreateGrayscaleImage( width, height );

            // lock destination bitmap data
            BitmapData dstData = dstImage.LockBits(
                new Rectangle( 0, 0, width, height ),
                ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed );

            // do the job
            unsafe
            {
                byte* dst = (byte*) dstData.Scan0.ToPointer( );
                int offset = dstData.Stride - width;

                // for each line
                for ( int y = 0; y < height; y++ )
                {
                    // for each pixel
                    for ( int x = 0; x < width; x++, dst++ )
                    {
                        *dst = (byte) ( texture[y, x] * 255.0f );
                    }
                    dst += offset;
                }
            }

            // unlock destination images
            dstImage.UnlockBits( dstData );

            return dstImage;
        }