drawtext

WinForms: Measure Text With No Padding

情到浓时终转凉″ 提交于 2019-12-11 05:56:57
问题 In a WinForms app, I am trying to measure the size of some text I want to draw with no padding . Here's the closest I've gotten... protected override void OnPaint(PaintEventArgs e) { DrawIt(e.Graphics); } private void DrawIt(Graphics graphics) { var text = "123"; var font = new Font("Arial", 32); var proposedSize = new Size(int.MaxValue, int.MaxValue); var measuredSize = TextRenderer.MeasureText(graphics, text, font, proposedSize, TextFormatFlags.NoPadding); var rect = new Rectangle(100, 100,

How do you apply a Scale Translation to a DrawingContext?

大兔子大兔子 提交于 2019-12-11 02:15:01
问题 I have a Canvas with a scale translation applied in XAML. Using DrawingContext I draw lines on the Canvas . I now need to add text to the screen. I thought with formatted text I could apply a translation, but neither Formatted Text or DrawingContext accepts RenderTransform . How do I apply a scale translation to the text so it will counter the scale translation of the canvas? ftext = New FormattedText("N", CultureInfo.GetCultureInfo("en-us"), Windows.FlowDirection.LeftToRight, face, Me

FFMPEG add text frames to the start of video

前提是你 提交于 2019-12-10 22:16:46
问题 I have some videos either in mp4 or webm format, and I'd like to use ffmpeg to add 4 seconds to the start of each video to display some text in the center with no sound. Some other requirements: try to avoid re-encoding the video need to maintain the quality (resolution, bitrate, etc) (optional) to make the text fade in/out I am new to ffmpeg and any help will be appreciated. thanks in advance Example ffprobe information for mp4 below: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':

Canvas drawtext positioning

社会主义新天地 提交于 2019-12-10 15:53:39
问题 I am creating a drawing tool, where user add text to image. While making the text draw to bitmap via canvas position is not being set properly. Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.RED); paint.setTypeface(tf); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(30); int xPos = layoutTextViewContainer.getLeft(); int yPos = layoutTextViewContainer.getTop(); canvas.drawText(text, xPos, yPos, paint); Paint Rect textRect = new Rect(); paint

TextRenderer.DrawText using GDI to render OTF Fonts?

谁都会走 提交于 2019-12-10 14:33:34
问题 I'm trying to draw text over a bitmap image and I've done some research and found that .NET/GDI+ doesn't support OTF fonts. I read somewhere that you could use TextRenderer.DrawText to render OTF fonts with GDI, but I can't seem to figure out how, nor does the quality compare to Graphics.DrawString in the least bit. First of all, is it possible to use OTF fonts at all in VS or did I read something incorrectly? Second, If the answer is TextRenderer.DrawText, how do I use the OTF fonts? It

QPainter::drawText, get bounding boxes for each character

核能气质少年 提交于 2019-12-10 10:08:22
问题 I'm using QPainter to draw multiline text on QImage. However, I also need to display a colored rectangle around each character's bounding box. So I need to know the bounding box that each character had when being drawn. For example, for painter.drawText(QRect(100, 100, 200, 200), Qt::TextWordWrap, "line\nline2", &r); I would need to get 10 rectangles, taking into account newlines, word-wrap, tabs, etc. For example, the rectangle of the second 'l' would be below the rectangle of the first 'l'

QPainter::drawText, get bounding boxes for each character

[亡魂溺海] 提交于 2019-12-05 21:54:57
I'm using QPainter to draw multiline text on QImage. However, I also need to display a colored rectangle around each character's bounding box. So I need to know the bounding box that each character had when being drawn. For example, for painter.drawText(QRect(100, 100, 200, 200), Qt::TextWordWrap, "line\nline2", &r); I would need to get 10 rectangles, taking into account newlines, word-wrap, tabs, etc. For example, the rectangle of the second 'l' would be below the rectangle of the first 'l' , instead of being to the right of 'e' , because of the newline. Something like the coordinates of the

Draw a text on a circle path in android

大兔子大兔子 提交于 2019-12-04 08:37:16
I need to draw a text on a circle path. I have tried the drawTextOnPath() method. But for texts like "fertile window" in the image attched, the text rotates and is not readable. Code I have used : customPath2.addArc(mCircleRectF, 30F, 64.28F); customPaint2.setAntiAlias(true); customPaint2.setDither(true); customPaint2.setStrokeWidth(mCircleStrokeWidth); customPaint2.setColor(Color.parseColor("#93BE66")); customPaint2.setStyle(Paint.Style.STROKE); customPaint2.setStrokeCap(Paint.Cap.ROUND); canvas.drawPath(customPath2, customPaint2); titlePaint.setColor(Color.parseColor("#ffffff")); titlePaint

How to add text to a video with ffmpeg and python

∥☆過路亽.° 提交于 2019-12-03 16:47:39
I've been trying to add text to an avi with ffmpeg and I can't seem to get it right. Please help: import subprocess ffmpeg = "C:\\ffmpeg_10_6_11.exe" inVid = "C:\\test_in.avi" outVid = "C:\\test_out.avi" proc = subprocess.Popen(ffmpeg + " -i " + inVid + " -vf drawtext=fontfile='arial.ttf'|text='test' -y " + outVid , shell=True, stderr=subprocess.PIPE) proc.wait() print proc.stderr.read() A colon ":" and a backslash "\" have special meaning when specifying the parameters for drawtext. So what you can do is to escape them by converting ":" to "\:" and "\" to "\\". Also you can enclose the path

Android canvas drawText y-position of text

*爱你&永不变心* 提交于 2019-12-03 14:38:44
问题 I'm using a Canvas to create a Drawable with some background and some text. The drawable is used as a compound drawable inside an EditText. The text is drawn via drawText() on the canvas, but I do have an issue with the y-position of the drawn text in some cases. In those cases parts of some characters are cut off (see image links). Characters without positioning issue: http://i50.tinypic.com/zkpu1l.jpg Characters with positioning issue, text contains 'g', 'j', 'q', etc.: http://i45.tinypic