SetAlphaBitmap not working
I'm using directshow, using VMR-7 IVMRWindowlessControl video..
I can't get SetAlphaBitmap to work.
SetAlphaBitmap returns S_OK, and acts like a bitmap was set on the video, but I see nothing.
Anyone have any ideas?
code snip 1...
Code:
// Set the rendering mode and number of streams.
IVMRFilterConfig* pConfig;
hr = m_pVmr->QueryInterface(IID_IVMRFilterConfig, (void**)&pConfig);
if(FAILED(hr))
{
TRACE("\nFailed to get IVMRFilterConfig interface");
CloseInterfaces();
return FALSE;
}
pConfig->SetRenderingMode(VMRMode_Windowless);
pConfig->SetNumberOfStreams(2);//must do this for VMR-7 to overlay a Bitmap image
SAFE_RELEASE(pConfig);
now the alpha overlay function, which does not work for me....
Code:
//load test bitmap...
HBITMAP hBmp = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_VMR));
//HWND of video window
HRESULT video::BlendImage2(HWND hWnd, HBITMAP hbm)
{
IVMRWindowlessControl* pWc = m_pWc;
LONG cx, cy;
HRESULT hr;
hr = pWc->GetNativeVideoSize(&cx, &cy, NULL, NULL);
if(FAILED(hr))
{ return hr; }
HDC hdc = GetDC(hWnd);
if(hdc == NULL)
{ return E_FAIL; }
HDC hdcBmp = CreateCompatibleDC(hdc);
ReleaseDC(hWnd,hdc);
if(hdcBmp == NULL)
{ return E_FAIL; }
BITMAP bm;
if (0 == GetObject(hbm,sizeof(bm),&bm))
{ DeleteDC(hdcBmp); return E_FAIL; }
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcBmp, hbm);
if (hbmOld == 0)
{ DeleteDC(hdcBmp); return E_FAIL; }
VMRALPHABITMAP bmpInfo;
ZeroMemory(&bmpInfo, sizeof(bmpInfo) );
bmpInfo.dwFlags = VMRBITMAP_HDC;
bmpInfo.hdc = hdcBmp;
// Show the entire bitmap in the top-left corner of the video image.
SetRect(&bmpInfo.rSrc, 0, 0, bm.bmWidth, bm.bmHeight);
bmpInfo.rDest.left = 0.f;
bmpInfo.rDest.top = 0.f;
bmpInfo.rDest.right = 1.0;//(float)bm.bmWidth / (float)cx;
bmpInfo.rDest.bottom = 1.0;//(float)bm.bmHeight / (float)cy;
bmpInfo.fAlpha = 1.0f;// Set the transparency value (1.0 is opaque, 0.0 is transparent).
IVMRMixerBitmap* pBmp;
hr = pWc->QueryInterface(IID_IVMRMixerBitmap,(LPVOID*)&pBmp);
if (SUCCEEDED(hr))
{
pBmp->SetAlphaBitmap(&bmpInfo);
pBmp->Release();
}
DeleteObject(SelectObject(hdcBmp,hbmOld));
DeleteDC(hdcBmp);
return hr;
}
Re: SetAlphaBitmap not working
I ended up having to write my own overlay stuff from scratch. never could get this working. maybe a hardware compatibility thing, I read on MSDN how this VMR7 overlay stuff was very hardware dependent.
I'm using directshow through Win32API with codeblocks and MinGW GCC compiler. everything worked fine except this. I don't understand why, wasted 5 days on it though. I very much dis-like how microsoft's libraries for directshow and directX are only written to be compatible out of the box with their compilers only.