[Direct Draw]How to make the overlay surface transparent? RRS feed

  • Question

  • Hi Friends,
    I am trying to create an overlay and make it transparent so that I can see the preview screen through the overlay.

    I was able to do this in my desktop PC by color keying. But when I try to execute the same code in my PPC device(windows mobile 5.0), it is not giving me the desired result.
    The overlay shows the preview screen, but any updation in the preview screen is not reflected. It is virtually like taking a snapshot of the preview screen and loading to the overlay surface. Eg: if I click on the start menu, I can hear the sound of start menu popping up, but the user can't see the popped up menu.

    What I want is to make the overlay transparent and any updation on the screen should be visible to the user.

    The device I am using is of RGB surface and it supports source colorkeying.

    This is my code

    //Trying to set the src color keying

    ZeroMemory(&ovfx, sizeof(ovfx));
    ovfx.dwSize = sizeof(ovfx);

    ovfx.dckSrcColorkey.dwColorSpaceLowValue = 0;    // setting the color key value as 0(black)

    ovfx.dckSrcColorkey.dwColorSpaceHighValue = 0   // setting the color key value as 0(black)

     DDBLTFX ddbltfx;
     ddbltfx.dwSize = sizeof(ddbltfx);
     ddbltfx.dwFillColor = 0;
    //Filling the surface with 0(which is the color key) to make it transparent
    hRet  = m_ pOverlaySurface->Blt(NULL, NULL,  NULL,DDBLT_COLORFILL | DDBLT_KEYSRCOVERRIDE,&ddbltfx);

    RECT rs = {0, 0, 240, 320}

    hRet = m_pOverlaySurface->UpdateOverlay(&rs, m_pPrimarySurface, &rs, dwFlag, &ovfx);

    Please help

    Thanks in advance

    Wednesday, April 2, 2008 4:25 AM

All replies

  • Hi SunilActivity,
    i have some problems like to you ,
    i want to do overlay on the video surface,
    i don't know how to do? can you help me
    Monday, April 7, 2008 2:33 AM
  • Hi,
    We need to specify a flag to create the overlay in video memory.

    Pls go thru the following code.
    static DDPIXELFORMAT g_ddpfOverlayFormats[] = {
        {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 24,  0xFF00, 0x0FF0, 0x00FF, 0},
        {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16,  0xF800, 0x07e0, 0x001F, 0},
        {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16,  0x7C00, 0x03e0, 0x001F, 0},
        {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('Y','U','V',0),0,0,0,0,0},
        {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('Y','U','Y','V'),0,0,0,0,0},
        {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('U','Y','V','Y'),0,0,0,0,0},
    #define NUM_OVERLAY_FORMATS (sizeof(g_ddpfOverlayFormats) / sizeof(g_ddpfOverlayFormats[0]))

    HRESULT ddrval = E_FAIL;
        DDSURFACEDESC ddsdOverlay = {0};
            ZeroMemory(&ddsdOverlay, sizeof(ddsdOverlay));
            ddsdOverlay.dwSize = sizeof(ddsdOverlay);
            ddsdOverlay.ddsCaps.dwCaps=DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY;
            ddsdOverlay.dwHeight = 100;
            ddsdOverlay.dwHeight = 100;
            // Try to create the overlay surface
            //ddrval = m_pDDraw->CreateSurface(&ddsdOverlay, &m_pOverlaySurface, NULL);
            int i=0;
                ddrval = m_pDDraw->CreateSurface(&ddsdOverlay, &m_pOverlaySurface, NULL);
            } while( FAILED(ddrval) && (++i < NUM_OVERLAY_FORMATS) );
    Monday, April 21, 2008 3:29 PM