Click or drag to resize
CanvasSpriteBatchDrawFromSpriteSheet Method (CanvasBitmap, Vector2, Rect, Vector4, Vector2, Single, Vector2, CanvasSpriteFlip)
[Win10_10586] Adds a sprite from a sprite sheet to the sprite batch, drawn at a specified offset, tinted with additional rotation and scale and optionally flipped.

Namespace:  Microsoft.Graphics.Canvas
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
Remarks

This API is only available when running on Windows 10 build 10586 (released November 2015) or greater.

The origin parameter is specified relative to the source bitmap. The image is then drawn such that the origin is in the position specified by the offset. The rotation and scale are performed around the origin.

The tint parameter is specified in non-premultiplied format.

The value of the tint parameter is a Vector4 that specifies the red, green, blue and alpha amounts to scale the bitmap's color by. The default value is Vector4.One, which would result in scaling all four color channels by 1, keeping everything the same. A value of Vector4(2, 1, 1, 1) would tint the sprite red by doubling the red amount of each source color. A value of Vector4(1, 1, 1, 0.5f) would draw the sprite at half opacity.

You can tint with a Windows.UI.Color type by using:

C#
void DrawSomeSprites(CanvasDrawingSession ds)
{
    using (var spriteBatch = ds.CreateSpriteBatch())
    {
        spriteBatch.Draw(image, destRect, new Vector4(Color.R, Color.G, Color.B, Color.A) / 255.0f);
    }
}
See Also