- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
文档 [ here ]说如果我们使用 DT_CALCRECT
标志,那么下面将完成:
Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the pRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text.
DT_CALCRECT
将使
DrawText
不是 绘制内容以便我应该做类似的事情
DrawTextExA(hdc, fromsqlite->descrip, -1, &rect, DT_CALCRECT, NULL);
// On debugging, I can see that rect is being modified in the above step.
if (DrawTextExA(hdc, fromsqlite->descrip, -1, &rect,
DT_LEFT | DT_EDITCONTROL | DT_WORDBREAK, NULL) == 0) {
MessageBox(NULL, L"DrawText failed", NULL, MB_OK);
}
rect
被延长。在我的情况下,虽然
fromsqlite->descrip
这是从
sqlite
中检索到的数据库始终被视为
single-line
文本。
最佳答案
DT_WORDBREAK
应添加以打破单行文本。DT_CALCRECT
应与最终格式结合以获得矩形。
文档:DrawText function (GDI 功能)
DT_WORDBREAK
Breaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-line feed sequence also breaks the line.If this is not specified, output is on one line.
RECT rc={ 0, 0, 200, 0 };
const wchar_t* text = L"word1 word2 word3 word4 word5";
UINT format = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_WORDBREAK;
DrawText(hdc, text, -1, &rc, format | DT_CALCRECT);
DrawText(hdc, text, -1, &rc, format);
word1 word2 word3
word4 word5
DT_EDITCONTROL
必要的?
text = L"SingleLinexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
format = DT_LEFT | DT_TOP | DT_WORDBREAK;
DrawText(hdc, text, -1, &rc, format | DT_CALCRECT);
DrawText(hdc, text, -1, &rc, format);
DT_EDITCONTROL
结合使用或其他标志,如
DT_WORD_ELLIPSIS
确保右侧没有溢出。
DrawTextEx
使用相同的
DT_XXXX
标志。
MultiByteToWideChar
转换为 UTF-16 ,而不是使用
DrawTextA
需要 ANSI 输入。
关于c - 如何使 'DrawText' 矩形恰好适合文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47068265/
绘制文本选项 有一个 '画' 指定是否应绘制文本的表达式。 http://www.ffmpeg.org/ffmpeg-filters.html#drawtext-1 我发现我们可以使用以下表达式在特定
我正在使用 ffmpeg 库在特定时间在视频上绘制文本,我成功了 我正在使用此命令将文本从上到下移动,但我无法确定 x 和 Y 从 x,y 移动到特定 x,y ffmpeg -i VideoInput
我们正在尝试使用 ffmpeg drawtext 来支持印地语字体。但是数据的顺序是不正确的。 印地语文本的 unicode 是这样传递的 1. पिता माता िस्रफ 但输出呈现为 Outp
我正在开发一个对 FFmpeg 进行系统调用的应用程序。 我找到了一种方法来隔离和淡出 drawtext 过滤器,但是渲染时间增加了大约 5 倍。 我只是想看看我提出的命令是否有明显错误。 ffmpe
我正在尝试设置此 FFmpeg 命令的 drawtext 何时开始,我尝试使用 start_number 但看起来它不会成功。 ffmpeg -i 1.mp4 -acodec aac -keyint_
我正在尝试使用 ffmpeg drawtext 过滤器将藏文呈现为视频。但有些字符没有正确呈现。 例如: སྤྱི་སྟེགས Expected render output 一些垂直太长的字符无法正确
我使用 shell_exec 在 PHP 中运行以下命令: ffmpeg -i $sourcePath -vf \"drawtext=text='$txt':fontfile='$fontPath':
我正在使用 ffmpeg 库在特定时间在视频上绘制文本,我成功了 我正在使用此命令将文本从上到下移动,但我无法确定 x 和 Y 从 x,y 移动到特定 x,y ffmpeg -i VideoInput
我在 ffmpeg 中为 drawtext 使用以下参数 ffmpeg -i input.gif -vf drawtext="fontfile='ariblk.ttf':text=' Hello
我必须在视频开头添加声明符几秒钟,水平居中,绿色背景,如何使用单个命令来完成并覆盖现有视频而不重新编码 最佳答案 如果您愿意将免责声明图像转换为视频剪辑,则可以将两个视频合并为一个序列而无需重新编码。
是否可以在一个 ffmpeg 命令中包含电影覆盖和绘制文本。 我尝试了命令,但它给出了错误 [drawtext @ 03B2BBC0] Key '"fontsize' not found. [draw
将一些代码从 D2007 移植到 XE2 时,我遇到了一个我无法理解的编译器错误。请参阅以下示例: procedure TForm1.FormPaint(Sender: TObject); var
如何在一张图像上显示多行 我尝试了命令,但它给出了错误 [NULL @ 0203D780] Unable to find a suitable output format for '[in][T1]'
我正在 Canvas 上绘制关于现在轮到谁的信息。我使用 validate() 两次使屏幕无效并再次绘制文本。但是使用 invalidate() 我正在重绘所有板,这会持续很长时间,有什么方法可以使
我在 Win32 程序中使用 DrawText 函数在屏幕顶部中央显示“本地”,在中央显示“服务器”。当我运行程序时,它显示“本地”而不是“服务器”。这是我的消息循环中的代码: case WM_PAI
我想在屏幕 Canvas 上绘制与第一个字符串相邻的第二个字符串。第二个字符串的起点应该是第一个字符串的宽度。我使用了Android的paint.measuretext()方法。但它返回的宽度小于实际
我的主要目标是收集用户输入并将其转换为黑色背景的视频,然后输入文本将从左向右移动,同时视频在背景中播放音频。 目前有人建议我使用“drawtext”,但我发现它不起作用。 我的命令: ffmpeg -
有没有办法检测文本何时传递给 DrawText被剪掉了? 我希望能够在给定的矩形中绘制任何文本(即已被 DrawText 剪裁,这意味着用户可能会错过文本的某些重要部分)。 我想获得显示剪切文本所需的
我正在使用 DrawText 将一些文本绘制到我在插件中制作的一堆矩形中。 现在我从嵌入式 python 接收到一个字符指针: char *a=PyString_AsString(value); 当我
我目前正在创建一个图像编辑器,并尝试使用 canvas.drawText() 在图像上绘制文本。到目前为止,我已经成功地做到了这一点,但是当用户输入太长的文本时,文本只会在页面外的一行上继续,并且不会
我是一名优秀的程序员,十分优秀!