Medialooks Knowledge Base Support Center

Contact Us

Text overlay

You can add text overlays to a video frame by using a single method - MFPrint.

This method includes the following parameters:

Parameter _bsText can be just plain text or it can contain the following XML tags:

Additional parameters are introduced as a string in order to achieve greater flexibility: adding new formatting options will not change the code for calling the method.

In order to add formatting, we can change the _bsExtraParam. Here are the available parameters:

A sample text overlay looks like:

// grab frame from source
MFFrame sourceFrame;
mySource.SourceFrameGet(-1, out sourceFrame, "");
// configure parameters for overlay
string textToOverlay = "My Sample Text";
double textSize = 3.0;
MF_RECT textRectangle= new MF_RECT();
textRectangle.dblHeight = 300;
textRectangle.dblPosX = 100;
textRectanglele.dblPosY = 150;
textRectangle.dblWidth = 600;
textRectangle.eRectType = eMFRectType.eMFRT_Absolute;
eMFTextFlags textFlags = eMFTextFlags.eMFT_WordBreaks;
string formattingParameters = "face='Times New Roman' weight='1.5' italic='true' bold='true' align='justify' vert-align='center' color='red'";
// overlay text
sourceFrame.MFPrint(textToOverlay, textSize, ref textRectangle, textFlags, formattingParameters);
// put frame to receiver
myReceiver.ReceiverFramePut(sourceFrame, -1, "");

Here is example of this code from Draw Frames Sample:

<text color=red>M</text>Formats <text size=0.9 face='Courier New'><b>IMFFrame::MFPrint</b></text> support:
<tab>- Different <text color=yellow>colors</text>
<tab>- Different <text size=1.0 face='Courier New'>fonts</text>
<tab>- Different styles: <b>bold</b> <i>italic</i> <u>underline</u> <s>strikeout</s>
<tab>- Different <text size=2.0>text</text> <text size=0.5>size</text>
<tab>- Add even pictures: <img size=3.0 src="C:\Users\Vsevolod\Pictures\logo.png"</img>