• ### Popular Now

• 11
• 14
• 12
• 10
• 11

#### Archived

This topic is now archived and is closed to further replies.

# Problem blending streams using alpha channel

This topic is 5122 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I thought I was finished developing my DS source filter, but not Maybe some of you already know what's about, but I'll explain it again: I have a direct3d offscreen surface, which I convert to a video stream using my own push source filter, which output pins minor type is MEDIASUBTYPE_ARGB32. In the overriden CSourceStream::FillBuffer method, I copy pixel by pixel the surface contents to the video sample buffer. If the pixel is the color key I use for alpha blending (green color) I set alpha to 0.0f (transparent). I then use VMR9 to mix it with other video streams.
//--- snip of code copy surface to video sample ---------------------------------------

pD3DSurface->LockRect(&d3dlr, 0, D3DLOCK_DONOTWAIT);

//solving flip effect converting between top-down and bottom-up bitmaps

pSurfaceBuffer = (BYTE *) d3dlr.pBits + d3dlr.Pitch*(surfaceDesc.Height - 1);

int m_lVidPitch  = surfaceDesc.Width * 4;

for (int i=0;i<(int)surfaceDesc.Height;i++)
{

//This method is used to take an alpha color (in this case green 0x##00FF00)

DWORD *pdwData = (DWORD*)pData;
DWORD *pdwSurfaceBuffer = (DWORD*)pSurfaceBuffer;

for (int j=0;j<(int)surfaceDesc.Width;j++)
{

if (pdwSurfaceBuffer[0] == 0xFF00FF00)
pdwData[0] = 0x0000FF00;
else
pdwData[0] = pdwSurfaceBuffer[0];

pdwData++; pdwSurfaceBuffer++;
}

pData += m_lVidPitch;
pSurfaceBuffer -= d3dlr.Pitch;

}

pD3DSurface->UnlockRect();
//-------------------------------------------------------------------------------------


It works fine while there is a video running under my "D3D surface" video stream, because front and back buffers are filled with the video data and after that my filter puts the objects in my D3D scene leaving transparent pixels as they are. But when the video stops, there is nothing "repainting" the buffers where my D3D surface clears to the color key, so my filter takes this pixels for transparent and doesn't modify them in the buffer. This obviously comes to a flick effect with the last two samples of the video and the object rendered to my surface repeated while I translate it along the scene. How can I solve this issue? Is there anyway to tell my filter "there is no other video stream running, clear buffers completly"? Or something... I'm a bit lost Thanks.. [edited by - crypting on April 15, 2004 9:24:42 AM]