CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    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;
    }
    Last edited by 12oclocker; October 27th, 2011 at 03:00 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured