尝试将带有 TextRenderer.DrawText 的透明文本添加到位图图像
Trying to add transparent text with TextRenderer.DrawText to a bitmap image
实际上,我正在尝试使用
在 C# 中向图像添加一些文本
System.Windows.Forms.TextRenderer.DrawText(Graphics, string, Rectangle, Color, TextFormaFlags)
我通过将图像加载到内存中来准备我的图像(它是 png),类似于
Image image = ImageCache.Get(...);
bitmap = new Bitmap(image);
graphic = Graphics.FromImage(bitmap);
然后我用上面的命令绘制我的文本。问题是无论我用什么颜色,甚至像
System.Drawing.Color.FromArgb(0,255,255,255)
不绘制透明度。我为
尝试了很多设置
graphics.TextRenderingHint
以及字体、透明度级别等的不同组合。这里有什么我不明白的地方吗?任何提示表示赞赏。
谢谢。
如评论中所述:如果您尝试使用
绘制透明文本
System.Windows.Forms.TextRenderer.DrawText
因为你在C#中寻找GDI带来的优势,你就是找不到。使用
System.Drawing.Graphics.DrawString
相反,即使自动换行的结果在 GDI+ 中稍逊一筹。
实际上,我正在尝试使用
在 C# 中向图像添加一些文本System.Windows.Forms.TextRenderer.DrawText(Graphics, string, Rectangle, Color, TextFormaFlags)
我通过将图像加载到内存中来准备我的图像(它是 png),类似于
Image image = ImageCache.Get(...);
bitmap = new Bitmap(image);
graphic = Graphics.FromImage(bitmap);
然后我用上面的命令绘制我的文本。问题是无论我用什么颜色,甚至像
System.Drawing.Color.FromArgb(0,255,255,255)
不绘制透明度。我为
尝试了很多设置graphics.TextRenderingHint
以及字体、透明度级别等的不同组合。这里有什么我不明白的地方吗?任何提示表示赞赏。
谢谢。
如评论中所述:如果您尝试使用
绘制透明文本System.Windows.Forms.TextRenderer.DrawText
因为你在C#中寻找GDI带来的优势,你就是找不到。使用
System.Drawing.Graphics.DrawString
相反,即使自动换行的结果在 GDI+ 中稍逊一筹。