Click here to Skip to main content
15,895,709 members

Problem in displaying the image over the playing video.

J.Surjith Kumar asked:

Open original thread
Am creating the video player using directshow in VC++. I created the video player successfully with some of the common controls. Now am trying to display the image over the playing video. Here is the Code:
C++
void CVMR9Dlg::OnBnClickedDrawimage()
{
        pVmr->QueryInterface(IID_IVMRMixerBitmap9, (void**)&pMixerBmp);
	ZeroMemory(&alphaBitmap, sizeof(alphaBitmap) );
	const float EDGE_BUFFER  = 0.04f;
	CDC * pdc = GetDC();
	CDC mCompatibleDC;
	HBITMAP hBitmap =LoadBitmap(AfxGetApp()>m_hInstance,
                                    MAKEINTRESOURCE(IDB_BITMAP1));
  	BITMAP bm;
        GetObject(hBitmap, sizeof(bm), &bm);
        int mBitmapWidth = bm.bmWidth;
	int mBitmapHeight= bm.bmHeight;
	mCompatibleDC.CreateCompatibleDC(pdc);
	mCompatibleDC.SelectObject(hBitmap);
	CRect reSrc(0,0,mBitmapWidth,mBitmapHeight);
	CRect reDst;
	//mVideoClass.ShowImage(&mCompatibleDC,reSrc);
	alphaBitmap.dwFlags |= VMR9AlphaBitmap_hDC;
	alphaBitmap.hdc = mCompatibleDC.m_hDC;
	alphaBitmap.rSrc = reSrc;
	CRect mRect;
	mRect.SetRect(0,0,45,75);
        LONG cx, cy;
        pWc->GetNativeVideoSize(&cx, &cy, NULL, NULL);
	// This value is used to reposition the bitmap in composition space.
	float fBmpCompWidth = (float)45 / (float)cx;
       //rDest specifies the destination rectangle in composition space (0.0f to 1.0f)
        alphaBitmap.rDest.right  = 1.0f - EDGE_BUFFER;
	alphaBitmap.rDest.left   = 1.0f - fBmpCompWidth- EDGE_BUFFER;
	float mTop = (float)(cy - 75) / (float)cy - EDGE_BUFFER;
	alphaBitmap.rDest.top = mTop;
	float mBottom = 1.0f - EDGE_BUFFER;
	alphaBitmap.rDest.bottom = mBottom; 
	pRect = alphaBitmap.rDest;
	// Set the transparency value (1.0 is opaque, 0.0 is transparent).
        alphaBitmap.fAlpha = 0.0;
	// Set the COLORREF so that the bitmap outline will be transparent
	alphaBitmap.dwFlags |= VMR9AlphaBitmap_SrcColorKey; 
        alphaBitmap.clrSrcKey = RGB(0, 255, 0);
	pMixerBmp->SetAlphaBitmap(&alphaBitmap);	
}

Its build successfully but am getting the screen shot as an image rather than getting the loaded bitmap.


Anyone help me to resolve from this error.

Thanks & Regards,
J.SurjithKumar
Tags: C++, C, VC++, MFC, DirectShow

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900