如何使抽绳的字体大小更大?
问题描述:
我找到了一些在图像上写文字的来源。
但我对图形课没有任何了解。
所以有人可以帮助我得到更大的字体大小?
这是我的源代码
I've found some source to write an text on image.
But I don't have any knowladge about graphic class.
So can somebody help me to get the font size bigger?
Here is my source code
private void write_text_on_image(string image_path)
{
var bmp = Bitmap.FromFile(image_path);
var newImage = new Bitmap(bmp.Width, bmp.Height + 50);
var gr = Graphics.FromImage(newImage);
gr.DrawImageUnscaled(bmp, 0, 0);
gr.DrawString("This is added text", SystemFonts.DefaultFont, Brushes.Black,
new RectangleF(0, bmp.Height-450, bmp.Width-300, 50));
string new_img_path = image_path.Replace("_1", "_2");
newImage.Save(new_img_path);
newImage.Dispose();
bmp.Dispose();
delete_old_img(image_path);
}
我的尝试:
使用SystemFonts.CaptionFont代替SystemFonts.DefaultFont
What I have tried:
Used "SystemFonts.CaptionFont" instead of SystemFonts.DefaultFont"
答
而不是DefaultFont创建一个您想要的族和大小的字体
Rather than DefaultFont create a Font of the family and size you want
Font f = new Font(new FontFamily("Verdana"), 10);
并在DrawString中使用该字体对象(f)而不是DefaultFont
And use that font object (f) in DrawString instead of DefaultFont
尝试创建自己的字体。请参阅字体类(System.Drawing) [ ^ ]
最好是你有一个私人成员r变量并在构造函数中创建对象。
Try to create your own font. See Font Class (System.Drawing)[^]
Preferably you have a private member variable and create the object in the constructor.
private Font myFont;
public MyClassName()
{
myFont = new Font("Arial", 14.0F, FontStyle.Bold);
}
private void write_text_on_image(string image_path)
{
...
gr.DrawString("This is added text", myFont, Brushes.Black, ...);
...
}