Text overlays




Text overlays


Text over video frames

- set the SetTextOverlay_String property with the text string to write (string options),
- set the SetTextOverlay_Font color and font size,
- set the SetTextOverlay_Transparent text transparency.
- set the SetTextOverlay_BkColor background color (useful only when TextOverlay_Transparency is disabled)
- set the SetTextOverlay_Align text alignment,
- set the SetTextOverlay_Left , SetTextOverlay_Right and SetTextOverlay_Top text location,
- invoke SetTextOverlay_Enabled to activate the text overlay.

Remark: a shadow can be draw under the text overlay when SetTextOverlay_Shadow is enabled, according to the SetTextOverlay_ShadowDirection and SetTextOverlay_ShadowColor values.

Alpha blending

To enable the alpha blending of the text overlays:

- enable SetTextOverlay_AlphaBlend
- set SetTextOverlay_AlphaBlendValue with a transparency value in the 0..255 range

Text scrolling

The text scrolling can be activated by enabling the SetTextOverlay_Scrolling property.
The scrolling speed is adjusted with the TextOverlay_Scrolling_Speed:

TextOverlay_Scrolling_Speed > 0 -> scrolling from right to left
TextOverlay_Scrolling_Speed < 0 -> scrolling from left to right
TextOverlay_Scrolling_Speed = 0 -> stops the scrolling

When a scrolling is completed (when the last character disappear from the video frame) the OnTextOverlayScrollingCompleted event occurs.
The TextOverlayIndex parameter of the OnTextOverlayScrollingCompleted event returns the index of the related text overlay.

Custom fonts

You can create a fully customised font by invoking TextOverlay_CreateCustomFont or TextOverlay_CreateCustomFont2

VideoGrabber.TextOverlay_CreateCustomFont (16, 30, 0, 0, 200, true, false, false, 2, 0, 0, 0, 0, "Wingdings")

Using several text overlays, each one having its own set of font / color / background

You can define up to 1000 different groups of text overlays settings, that will be drawn at the same time over video frames, each one having different TextOverlay_... values.

Each group is selected by setting TextOverlay_Selector to the corresponding value (in the [0..999] range). By default the TextOverlay_... settings concern the 1st group (TextOverlay_Selector = 0).

At startup TVideoGrabber does not allocate the resources for 1000 sets of text overlays. By default only one font and one parameter sets are allocated (corresponding to TextOverlay_Selector = 0).
When using more than one text overlay, the required resource allocation is done when the TextOverlay_Selector property receives a greater value than the latest highest value (see the remark below).

To use more than one group simply set TextOverlay_Selector with the index of the group (in the 0..999 range) before reading or setting the corresponding TextOverlay_... properties.

Look at the TextOverlay_Selector property for same code.

when using more text overlays, the additional memory and fonts required are allocated when a new TextOverlay_Selector value set (and greater than the highest value previously used).
E.g. if the previous value of TextOverlay_Selector was 5 and if you set now TextOverlay_Selector = 20, this will allocate 15 new fonts and parameter sets, one for each new text overlay (for a total of 20 fonts and parameter sets allocated).
So if you need e.g. only 5 different text overlays in your app (in this case TextOverlay_Selector will be used in the [0..4] range), be sure to NEVER set TextOverlay_Selector to a value GREATER THAN 4, to prevent allocating more resources than needed (by allocating useless text overlay fonts and parameter sets).