如何在C#或vb.net添加文本图像 [英] how do i add text to image in c# or vb.net
本文介绍了如何在C#或vb.net添加文本图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
是一个平均的Visual Studio程序员,我需要一个函数或例程将文本添加到图像的按钮,而不是像我在图像中显示
am an average visual studio programmer, i need a function or routine to add text to the button of an image not on it like i showed in the image
请想法
- AM程序的Visual Studio
2008年,在WinXP。 - 的应用程序是一个控制台应用程序。
- 它将在WIN2000以上运行
- 我将保存结果图像后
添加文本到文件
推荐答案
-
创建你想要的新大小的位图
Create a bitmap with the new size you want
在新的位图顶部的原始图像复制
Copy the original image at the top of the new bitmap
写上你想要的文字到新的位图
Write the text you want onto the new bitmap
事情是这样的:(未经测试)
Something like this: (untested)
var bmp = Bitmap.FromFile("orig.jpg"); var newImage = new Bitmap(bmp.Width, bmp.Height + 50); var gr = Graphics.FromImage(newImage); gr.DrawImageUnscaled(bmp, 0, 0); gr.DrawString("this is the added text", SystemFonts.DefaultFont, Brushes.Black , new RectangleF(0, bmp.Height, bmp.Width, 50)); newImage.Save("newImg.jpg");
这篇关于如何在C#或vb.net添加文本图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文