使用 DrawText 绘制文本的结尾

发布于 2024-12-11 12:46:24 字数 144 浏览 2 评论 0原文

当目标矩形太小时,TextRenderer.DrawText() 是否能够绘制文本的末尾?

TextFormatFlags.Bottom 没有帮助我。

换句话说:如何在其顶部边缘剪切文本?

Is TextRenderer.DrawText() capable to draw the end of a text when destination rectangle is too small?

TextFormatFlags.Bottom didn't helped me.

In others words: how to clip text on its top edge?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2024-12-18 12:46:24

创建一个内存位图,其大小为“溢出区域”。使用 -Y 坐标将文本字符串绘制到此溢出区域,以便它绘制出与要剪辑的区域对齐的图像顶部。现在,您可以在图像中绘制溢出文本,将其绘制在您想要的位置。

例如,如果您想要在只能显示 75 像素的区域中绘制 100 像素高的文本,请创建一个 25 像素高的图像,并将文本绘制到该图像的 y=-75 处。

Create an in memory bitmap that is the size of the "overflow area". Draw your text string to this overflow area with a -Y coord that so that it draws off the top of the image that lines up with the area you want to clip to. You now have the overflow text in an image that you can paint where you want it.

For example, if you want to draw text that is 100 pixel high in an area that can only show 75 pixels, create a 25 pixel high image, and draw your text to that image at y=-75.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文