SurfaceLoader.FromSurface Method |
Language: |
Loads a surface from another surface with color conversion.
Visual Basic Public Shared Sub FromSurface( _
ByVal destSurface As Surface, _
ByVal srcSurface As Surface, _
ByVal srcRectangle As Rectangle, _
ByVal filter As Filter, _
ByVal colorKey As Integer _
)C# public static void FromSurface(
Surface destSurface,
Surface srcSurface,
Rectangle srcRectangle,
Filter filter,
int colorKey
);C++ public:
static void FromSurface(
Surface^ destSurface,
Surface^ srcSurface,
Rectangle srcRectangle,
Filter filter,
int colorKey
);JScript public static function FromSurface(
destSurface : Surface,
srcSurface : Surface,
srcRectangle : Rectangle,
filter : Filter,
colorKey : int
);
destSurface Microsoft.DirectX.Direct3D.Surface
A Surface object that represents the destination surface.srcSurface Microsoft.DirectX.Direct3D.Surface
A Surface object that represents the source surface.srcRectangle System.Drawing.Rectangle
A Rectangle object that represents the source rectangle.filter Microsoft.DirectX.Direct3D.Filter
One or more members of the Filter enumeration that control how the image is filtered.colorKey System.Int32
Integer value that represents the color to replace with transparent black, or 0 to disable the colorKey. This value is always a 32-bit ARGB color, regardless of the source image format. alpha is significant and should usually be set to 0xFF for opaque color keys. Thus, for opaque black, the value is equal to 0xFF000000.
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