Share via


TextureLoader.FromStream Method (Device, Stream)

Creates a texture from a file in memory.

Namespace: Microsoft.WindowsMobile.DirectX.Direct3D
Assembly: Microsoft.WindowsMobile.DirectX (in microsoft.windowsmobile.directx.dll)

Syntax

'Declaration
Public Shared Function FromStream ( _
    device As Device, _
    stream As Stream _
) As Texture
'Usage
Dim device As Device
Dim stream As Stream
Dim returnValue As Texture

returnValue = TextureLoader.FromStream(device, stream)
public static Texture FromStream (
    Device device,
    Stream stream
)
public:
static Texture^ FromStream (
    Device^ device, 
    Stream^ stream
)
public static Texture FromStream (
    Device device, 
    Stream stream
)
public static function FromStream (
    device : Device, 
    stream : Stream
) : Texture
Not applicable.

Parameters

  • device
    A Device that represents the device to associate with the texture.
  • stream
    A Stream from which to create the texture.

Return Value

A Texture that represents the created texture object.

Exceptions

Exception type Condition

InvalidCallException

The method call is invalid. For example, a method's parameter might contain an invalid value.

OutOfMemoryException

Direct3D could not allocate sufficient memory to complete the call.

Remarks

This method supports the following file formats: .bmp, .dds, .jpg, .png, and .gif.

Example

The following example demonstrates how to use the FromStream method.

' This code example is taken from the
' Direct3D Mobile Texture Sample of the
' .NET Compact Framework Samples in the SDK

' Called whenever the rendering device is reset
Friend Sub OnResetDevice(ByVal sender As Object, ByVal e As EventArgs)
    Dim dev As Device = CType(sender, Device)
    ' Turn off culling, so we see the front and back of the triangle.
    dev.RenderState.CullMode = Cull.None
    ' Turn off D3D lighting.
    dev.RenderState.Lighting = False
    ' Turn on the ZBuffer.
    dev.RenderState.ZBufferEnable = True
    ' Turn on perspective correction for textures.
    ' This provides a more accurate visual at the cost
    ' of a small performance overhead.
    dev.RenderState.TexturePerspective = True
    ' Now create the texture.
    texture = TextureLoader.FromStream(dev, _
      [Assembly].GetExecutingAssembly().GetManifestResourceStream("Texture.Content.Banana.bmp"))

End Sub
// This code example is taken from the
// Direct3D Mobile Texture Sample of the
// .NET Compact Framework Samples in the SDK

// Called whenever the rendering device is reset
void OnResetDevice(object sender, EventArgs e)
{
    Device dev = (Device)sender;
    // Turn off culling, so we see the front and back of the triangle
    dev.RenderState.CullMode = Cull.None;
    // Turn off D3D lighting
    dev.RenderState.Lighting = false;
    // Turn on the ZBuffer
    dev.RenderState.ZBufferEnable = true;
    // Turn on perspective correction for textures
    // This provides a more accurate visual at the cost
    // of a small performance overhead
    dev.RenderState.TexturePerspective = true;
    // Now create our texture

    texture = TextureLoader.FromStream(dev,
        Assembly.GetExecutingAssembly().GetManifestResourceStream(
        "Texture.Content.Banana.bmp"));
}

Platforms

Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Compact Framework

Supported in: 2.0

See Also

Reference

TextureLoader Class
TextureLoader Members
Microsoft.WindowsMobile.DirectX.Direct3D Namespace