C# 如何将背景图像设置为动态生成的图像
我正在使用以下代码创建一些动态图像C# 如何将背景图像设置为动态生成的图像,c#,gdi,C#,Gdi,我正在使用以下代码创建一些动态图像 System.Drawing.Image img = new Bitmap(300, 600); Graphics drawing = Graphics.FromImage(img); //paint the background drawing.Clear(System.Drawing.Color.White); //create a brush for the text Brush textBrush = new SolidBrush(textCol
System.Drawing.Image img = new Bitmap(300, 600);
Graphics drawing = Graphics.FromImage(img);
//paint the background
drawing.Clear(System.Drawing.Color.White);
//create a brush for the text
Brush textBrush = new SolidBrush(textColor);
drawing.DrawString(text, font, textBrush, 0, 0);
drawing.Save();
textBrush.Dispose();
drawing.Dispose();
我想用一个图像(公司标志)来代替白色背景,使它看起来像一个水印。我如何才能做到这一点?将您的textBrush定义更改为如下所示:
int alpha = 128; // range from 0 (transparent) to 255 (opaque)
Brush textBrush = new SolidBrush(Color.FromArgb(alpha, textColor);