我想从我从数据库中获得的文本生成一个图像。我知道怎么做没问题,但是我需要帮助的是如何根据有多少文本来动态缩小或增大图像的边界。我不知道数据库列中会有多少文本。有没有办法以某种方式在生成的图像中包装文本?
谢谢!
发布于 2010-10-22 00:14:54
如果你知道你想要的矩形有多大,你可以像下面这样。
Bitmap bmp = new Bitmap(1000,1000);
using (Graphics g = Graphics.FromImage(bmp))
{
string s = "This string will be wrapped in the output rectangle";
RectangleF rectf = new RectangleF (10, 100, 200, 200);
g.DrawString(s, DefaultFont, Brushes.Red, rectf);
this.BackgroundImage = bmp; //For testing purposes set the form's background to the image
}
https://stackoverflow.com/questions/3989304
复制相似问题