SFML.Graphics.Image.Image C# (CSharp) Method

Image() public method

Construct the image directly from an array of pixels
public Image ( System.Color pixels ) : System
pixels System.Color 2 dimensions array containing the pixels
return System
        public Image(Color[,] pixels) :
            base(IntPtr.Zero)
        {
            uint Width = (uint)pixels.GetLength(0);
            uint Height = (uint)pixels.GetLength(1);

            // Transpose the array (.Net gives dimensions in reverse order of what SFML expects)
            Color[,] transposed = new Color[Height, Width];
            for (int x = 0; x < Width; ++x)
                for (int y = 0; y < Height; ++y)
                    transposed[y, x] = pixels[x, y];

            unsafe
            {
                fixed (Color* PixelsPtr = transposed)
                {
                    CPointer = sfImage_createFromPixels(Width, Height, (byte*)PixelsPtr);
                }
            }

            if (CPointer == IntPtr.Zero)
                throw new LoadingFailedException("image");
        }

Same methods

Image::Image ( Image copy ) : System
Image::Image ( IntPtr cPointer ) : System
Image::Image ( System.Stream stream ) : System
Image::Image ( byte bytes ) : System
Image::Image ( string filename ) : System
Image::Image ( uint width, uint height ) : System
Image::Image ( uint width, uint height, System.Color color ) : System
Image::Image ( uint width, uint height, byte pixels ) : System