gpt4 book ai didi

c# - 动态文本到图像

转载 作者:行者123 更新时间:2023-11-30 22:43:22 25 4
gpt4 key购买 nike

我想根据从数据库中获取的文本生成图像。我知道该怎么做没问题,但是我需要帮助的地方是如何根据有多少文本动态缩小或扩大图像的边界。我不知道数据库列中会有多少文本。有没有办法以某种方式在生成的图像中包装文本?

谢谢!

最佳答案

如果你知道你想要矩形有多大,你可以像下面这样。

        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


}

关于c# - 动态文本到图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3989304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com