CanvasSpriteBatchDrawFromSpriteSheet Method (CanvasBitmap, Matrix3x2, Rect, Vector4) |
Namespace: Microsoft.Graphics.Canvas
public void DrawFromSpriteSheet( CanvasBitmap bitmap, Matrix3x2 transform, Rect sourceRect, Vector4 tint )
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); } }