/******************************Public*Routine******************************\ * SetAppImage * \**************************************************************************/ HRESULT CMovie::SetAppImage( VMR9AlphaBitmap* lpBmpInfo ) { IVMRMixerBitmap9* pBmp; HRESULT hres = m_Wc->QueryInterface(IID_IVMRMixerBitmap9, (LPVOID *)&pBmp); if(SUCCEEDED(hres)) { hres = pBmp->SetAlphaBitmap(lpBmpInfo); pBmp->Release(); } return hres; }
bool CImageMixer_VMR9::SetBitmap(HBITMAP hbm,int Opacity,COLORREF TransColor,RECT *pDestRect) { IVMRMixerBitmap9 *pMixerBitmap; IVMRWindowlessControl9 *pWindowlessControl; LONG NativeWidth,NativeHeight; BITMAP bm; VMR9AlphaBitmap ab; HRESULT hr; if (!CreateMemDC()) return false; if (FAILED(m_pRenderer->QueryInterface(IID_IVMRMixerBitmap9, reinterpret_cast<LPVOID*>(&pMixerBitmap)))) return false; m_pRenderer->QueryInterface(IID_IVMRWindowlessControl9, reinterpret_cast<LPVOID*>(&pWindowlessControl)); if (FAILED(pWindowlessControl->GetNativeVideoSize(&NativeWidth,&NativeHeight, NULL,NULL)) || NativeWidth==0 || NativeHeight==0) { NativeWidth=1440; NativeHeight=1080; } pWindowlessControl->Release(); ::SelectObject(m_hdc,hbm); ab.dwFlags=VMR9AlphaBitmap_hDC; if (TransColor!=CLR_INVALID) ab.dwFlags|=VMR9AlphaBitmap_SrcColorKey; ab.hdc=m_hdc; ab.pDDS=NULL; ::GetObject(hbm,sizeof(BITMAP),&bm); ::SetRect(&ab.rSrc,0,0,bm.bmWidth,bm.bmHeight); ab.rDest.left=(float)pDestRect->left/(float)NativeWidth; ab.rDest.top=(float)pDestRect->top/(float)NativeHeight; ab.rDest.right=(float)pDestRect->right/(float)NativeWidth; ab.rDest.bottom=(float)pDestRect->bottom/(float)NativeHeight; ab.fAlpha=(float)Opacity/100.0f; ab.clrSrcKey=TransColor; hr=pMixerBitmap->SetAlphaBitmap(&ab); pMixerBitmap->Release(); if (FAILED(hr)) { ::SelectObject(m_hdc,m_hbmOld); return false; } return true; }