Click or drag to resize
CanvasSpriteBatchDrawFromSpriteSheet Method (CanvasBitmap, Rect, Rect, Vector4, CanvasSpriteFlip)
[Win10_10586] Adds a sprite from a sprite sheet to the sprite batch, scaled to fill a rectangle, tinted and optionally flipped.

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

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

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:

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