SurfaceLoader.FromSurface Method |
Language: |
Loads a surface from another surface with color conversion.
Writing to a surface level other than zero does not cause the dirty rectangle to be updated. If SurfaceLoader.FromSurface is called and the surface is not already dirty (which is unlikely under normal usage scenarios), the application must explicitly call Texture.AddDirtyRect on the surface.
Exceptions
InvalidCallException The method call is invalid. For example, a method's parameter might contain an invalid value. InvalidDataException The data is invalid.
Copy a Texture
This example demonstrates how to copy a texture.
A texture is loaded from a file and duplicated, and all of its AliceBlue color is replaced with transparent black. An area that is ten pixels square from the top right corner of the texture is copied.
In the following C# code example, device is assumed to be the rendering Device, and FlagColorsInverted.bmp is assumed to be in the current directory.
[C#]
using Microsoft.DirectX.Direct3D; using System.Drawing; Surface s = null; PaletteEntry[] pal = new PaletteEntry[256]; // Set up the surface for our surface loader. s = device.CreateOffscreenPlainSurface(32, 32, Format.A8R8G8B8, Pool.Default); Surface k = TextureLoader.FromFile(device, "FlagColorsInverted.bmp").GetSurfaceLevel(0); SurfaceLoader.FromSurface(s, out pal, new Rectangle(0,0,9,9), k, out pal, new Rectangle(0,0,9,9), Filter.Box, Color.AliceBlue.ToArgb());
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center