Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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());