public static Texture2D FromStream(Stream stream) { if (stream.CanSeek && stream.Position == stream.Length) { stream.Seek(0, SeekOrigin.Begin); } int width, height, len; IntPtr pixels = FNA3D.ReadImageStream( stream, out width, out height, out len ); Texture2D result = new Texture2D( width, height ); result.SetDataPointerEXT( 0, null, pixels, len ); FNA3D.FNA3D_Image_Free(pixels); return(result); }
public static Texture2D FromStream(GraphicsDevice graphicsDevice, Stream stream) { if (stream.CanSeek && stream.Position == stream.Length) { stream.Seek(0, SeekOrigin.Begin); } // Read the image data from the stream int width, height, len; IntPtr pixels; FNAPlatform.TextureDataFromStreamPtr( stream, out width, out height, out pixels, out len ); // Create the Texture2D from the raw pixel data Texture2D result = new Texture2D( graphicsDevice, width, height ); result.SetDataPointerEXT( 0, null, pixels, len ); Marshal.FreeHGlobal(pixels); return(result); }
public static Texture2D FromStream( GraphicsDevice graphicsDevice, Stream stream, int width, int height, bool zoom ) { if (stream.CanSeek && stream.Position == stream.Length) { stream.Seek(0, SeekOrigin.Begin); } int realWidth, realHeight, len; IntPtr pixels = FNA3D.ReadImageStream( stream, out realWidth, out realHeight, out len, width, height, zoom ); Texture2D result = new Texture2D( graphicsDevice, realWidth, realHeight ); result.SetDataPointerEXT( 0, null, pixels, len ); FNA3D.FNA3D_Image_Free(pixels); return(result); }
public static Texture2D FromStream( GraphicsDevice graphicsDevice, Stream stream, int width, int height, bool zoom ) { // Read the image data from the stream int realWidth, realHeight, len; IntPtr pixels; FNAPlatform.TextureDataFromStreamPtr( stream, out realWidth, out realHeight, out pixels, out len, width, height, zoom ); // Create the Texture2D from the raw pixel data Texture2D result = new Texture2D( graphicsDevice, realWidth, realHeight ); result.SetDataPointerEXT( 0, null, pixels, len ); Marshal.FreeHGlobal(pixels); return(result); }