Showing something over running video? You can see my previous article to show an image over video. But this time, I am going to do some more artwork or text work over running video.
Displaying text over video? This project has some similarities with my previous project, but it is not much similar. Here the text also scrolls over video.
It is a prerequisite to read my article which displays image over video. This is because in that article, I have explained everything which is required to display an image over video, and displaying the text is not much different. So here in this article, I will just stick to the working code which is needed to display text over video.
Prepare the Ground with IVMRMixerControl9
First of all we need to set some preferences for mixing. Because the default mixing preferences are not good for blending the text over video, in the code below I am doing the same:
dwPrefs |= MixerPref_PointFiltering;
dwPrefs &= ~(MixerPref_BiLinearFiltering);
Preparing the Image From Text
Now we need to make the image having the text we want to show over video.
CDC * pdc = GetDC();
CSize strSize = mCompatibleDC.GetTextExtent(strFinish);
Showing the Text Over Video
Now we will prepare for showing the image with text over video.
ZeroMemory(&bmpInfo, sizeof(bmpInfo) );
bmpInfo.dwFlags |= VMRBITMAP_HDC;
bmpInfo.hdc = pDC->m_hDC;
LONG cx, cy;
pWC->GetNativeVideoSize(&cx, &cy, NULL, NULL);
bmpInfo.rSrc = Rect;
bmpInfo.rDest.right = 1.0f;
bmpInfo.rDest.left = 0.0f;
bmpInfo.rDest.top = (float)(cy - Rect.Height()) / (float)cy - EDGE_BUFFER;
bmpInfo.rDest.bottom = 1.0f - EDGE_BUFFER;
bmpInfo.fAlpha = 1.0;
All is done. Now you can blend any text over video.
If you are interested in more information, see my blog.
- 26 Sep 2006 First version