[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Video overlay / VMRMixerBitmap doesn't show

Asked by Daeljan in DirectX Graphics & Game Programming, Multimedia Programming, Video Editing

Tags: overlay, video

Ok, I'm going to include a code snippet (with all error handling and cleanup removed) to help with this one. I'm using the VMR to render the video stream, and I want to overlay a bitmap image. As I understand, the Mixer bitmap serves this purpose. The video displays, but the overlay doesn't, and I cant see why - I have scratched my head for a while over this one, and searched the internet too - it seems to me that it should work (I'm using managed extensions to C++ btw). I'd be grateful if someone could point out the error of my ways...

This is how I obtain the mixer bitmap:

 pin_ptr<IVMRMixerBitmap9*> pPinnedVMRMixerBitmap9 = &pVMRMixerBitmap9;
 hResult = pVideoMixingRenderer->QueryInterface(IID_IVMRMixerBitmap, (void**)(&pPinnedVMRMixerBitmap9));

 pVMRMixerBitmap9 = (IVMRMixerBitmap9 *)pPinnedVMRMixerBitmap9;
 InitialiseVMRMixerBitmap();

And this is the  InitialiseVMRMixerBitmap() body:

void InitialiseVMRMixerBitmap()
{
 HRESULT hResult = NOERROR;
 Graphics ^pGraphics = nullptr;
 IntPtr pBitmapHDeviceContext = IntPtr::Zero;
 IntPtr pHBitmap = IntPtr::Zero;
 HDC hDeviceContext = (HDC)0;
      
 pVMR9AlphaBitmap = new VMR9AlphaBitmap();
      
 /// Get current Alpha Bitmap parameters
 hResult = pVMRMixerBitmap9->GetAlphaBitmapParameters(pVMR9AlphaBitmap);

 /// Put this into a know condition
 memset(pVMR9AlphaBitmap, 0, sizeof(VMR9AlphaBitmap));

 /// Disable the them by setting this enumeration and writing them back to the mixer
 pVMR9AlphaBitmap->dwFlags = VMR9AlphaBitmap_Disable;
 hResult = pVMRMixerBitmap9->UpdateAlphaBitmapParameters(pVMR9AlphaBitmap);

 /// This is the image to be overlayed
 Bitmap ^pBitmap = gcnew Bitmap(320, 240, PixelFormat::Format24bppRgb);
 Graphics ^pTestGraphics = Graphics::FromImage(pBitmap);
 pTestGraphics->DrawLine(gcnew Pen(Color::Red), 0, 0, pBitmap->Width, pBitmap->Height);

 Color keyColor = Color::White;
            
 /// Here we have some managed GDI - native voodoo
 pGraphics = Graphics::FromImage(pBitmap);
 pBitmapHDeviceContext = pGraphics->GetHdc();
 hDeviceContext = CreateCompatibleDC((HDC)pBitmapHDeviceContext.ToPointer());
 pHBitmap = pBitmap->GetHbitmap();
 SelectObject(hDeviceContext, (HGDIOBJ)pHBitmap.ToPointer());

 /// Now we can configure the alpha bitmap to use the GDI device context
 pVMR9AlphaBitmap = new VMR9AlphaBitmap();
            
 /// Bitwise combination of flags from the VMR9AlphaBitmapFlags enumeration type.
 pVMR9AlphaBitmap->dwFlags = VMR9AlphaBitmap_hDC | VMR9AlphaBitmap_SrcColorKey | VMR9AlphaBitmap_FilterMode;
            
 /// Specifies the handle to the device context for the bitmap. Specify NULL if the bitmap is located in a Direct3D surface.
 pVMR9AlphaBitmap->hdc = hDeviceContext;

 /// Specifies the source rectangle in either the GDI device context or the DirectDraw surface.
 pVMR9AlphaBitmap->rSrc.top = 0;
 pVMR9AlphaBitmap->rSrc.left = 0;
 pVMR9AlphaBitmap->rSrc.bottom = (LONG)pBitmap->Height;
 pVMR9AlphaBitmap->rSrc.right = (LONG)pBitmap->Width;

 /// Specifies the destination rectangle in composition space.
 pVMR9AlphaBitmap->rDest.top = 0;
 pVMR9AlphaBitmap->rDest.left = 0;
 pVMR9AlphaBitmap->rDest.bottom = 1;
 pVMR9AlphaBitmap->rDest.right = 1;
            
 /// Specifies the source color key.      
 pVMR9AlphaBitmap->clrSrcKey = ColorTranslator::ToWin32(keyColor);
 pVMR9AlphaBitmap->pDDS = NULL;
            
 /// Specifies flags from the VMRMixerPrefs enumeration, which control how the VMR mixes the image.
 /// The MixerPref_PointFiltering flag is particularly useful for images that contain text and do
 /// not need to be stretched prior to mixing.
 pVMR9AlphaBitmap->dwFilterMode = MixerPref_PointFiltering;
            
 /// Specifies the alpha blending value; must be a value from 0.0 to 1.0 (inclusive).
 pVMR9AlphaBitmap->fAlpha = 1.0;

 /// To remove the bitmap, set the VMR9AlphaBitmap_Disable flag in the VMR9AlphaBitmap structure
 /// and call SetAlphaBitmap again.
 hResult = pVMRMixerBitmap9->SetAlphaBitmap(pVMR9AlphaBitmap);
            
 pVMRMixerBitmap9->UpdateAlphaBitmapParameters(pVMR9AlphaBitmap);
}
[+][-]10/18/07 06:28 PM, ID: 20105910Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: DirectX Graphics & Game Programming, Multimedia Programming, Video Editing
Tags: overlay, video
Sign Up Now!
Solution Provided By: Computer101
Participating Experts: 1
Solution Grade: A
 
[+][-]08/30/07 04:40 AM, ID: 19799067Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/11/07 02:31 AM, ID: 20055312Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10/11/07 03:17 AM, ID: 20055517Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/16/07 01:16 AM, ID: 20083823Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_2_20070628