ARCed.XnaExtensions.ToTexture C# (CSharp) Method

ToTexture() public static method

Converts a Image to a Texture2D and returns it.
public static ToTexture ( this image, GraphicsDevice device ) : Microsoft.Xna.Framework.Graphics.Texture2D
image this Image to convert
device GraphicsDevice Texture graphics device
return Microsoft.Xna.Framework.Graphics.Texture2D
        public static Texture2D ToTexture(this Image image, GraphicsDevice device)
        {
            Texture2D texture = null;
            using (var stream = new MemoryStream())
            {
                image.Save(stream, ImageFormat.Png);
                stream.Seek(0, SeekOrigin.Begin);
                texture = Texture2D.FromStream(device, stream);
            }
            return texture;
        }