Exemple #1
0
 /// <summary>
 /// Draws an image, but tinted by the tint color.
 /// </summary>
 /// <param name="g">The graphics to draw to.</param>
 /// <param name="image">The image to draw.</param>
 /// <param name="destRect">The rectangle the image should draw in.</param>
 /// <param name="tintColor">The color to tint the image.</param>
 /// <param name="srcX">The source x of the image to draw from. Defaults to 0 (left).</param>
 /// <param name="srcY">The source y of the image to draw from. Defaults to 0 (top).</param>
 /// <param name="srcWidth">The source width of the image to draw from. Defaults to -1 (will use Image.Width).</param>
 /// <param name="srcHeight">The source height of the image to draw from. Defaults to -1 (will use Image.Width).</param>
 public static void DrawImageTinted(this Graphics g, Image image, Rectangle destRect, Color tintColor,
                                    int srcX = 0, int srcY = 0, int srcWidth = -1, int srcHeight = -1)
 {
     using var attribs = new ImageAttributes();
     attribs.SetTintColorMatrix(tintColor);
     g.DrawImageAttributed(image, destRect, srcX, srcY, srcWidth, srcHeight, attribs);
 }