Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// <param name="G"> The Graphic to draw the image </param>
- /// <param name="R"> The Rectangle area of image </param>
- /// <param name="_Image"> The image that the custom color applies on it</param>
- /// <param name="C">The Color that be applied to the image </param>
- /// <remarks></remarks>
- /// </summary>
- public void DrawImageWithColor(Graphics G, Rectangle R, Image _Image, Color C)
- {
- float[][] ptsArray = new float[][]
- {
- new float[] { Convert.ToSingle((double)C.R / 255.0), 0f, 0f, 0f, 0f },
- new float[] { 0f, Convert.ToSingle((double)C.G / 255.0), 0f, 0f, 0f },
- new float[] { 0f, 0f, Convert.ToSingle((double)C.B / 255.0), 0f, 0f },
- new float[] { 0f, 0f, 0f, Convert.ToSingle((double)C.A / 255.0), 0f },
- new float[] { Convert.ToSingle((double)C.R / 255.0),
- Convert.ToSingle((double)C.G / 255.0),
- Convert.ToSingle((double)C.B / 255.0), 0f,
- Convert.ToSingle((double)C.A / 255.0) }
- };
- System.Drawing.Imaging.ImageAttributes imgAttribs = new System.Drawing.Imaging.ImageAttributes();
- imgAttribs.SetColorMatrix(new System.Drawing.Imaging.ColorMatrix(ptsArray), System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Default);
- G.DrawImage(_Image, R, 0, 0, _Image.Width, _Image.Height, GraphicsUnit.Pixel, imgAttribs);
- _Image.Dispose();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement