Sign in to follow this  

AVIStreamGetFrame and Direct3d 9

Recommended Posts

Hey man!

You need to get the DIB(device-independent bitmap) information for the surface first.

I am assuming that you know how to use the DirectShow functions such as AVIStreamGetFrame.

This can be done as follows:

lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, lFrame);

I haven't tested this part so don't kill me if it's wrong.

Hopefully this will be a 'file in memory' and it can be loaded into the surface using the D3DXLoadSurfaceFromFileInMemory function.

If you don't already know the D3DXLoadSurfaceFromFileInMemory function takes the following parameters in order:

LPDIRECT3DSURFACE9 pDestSurface: A pointer to the surface you are trying to draw to.

CONST PALETTEENTRY *pDestPalette: A pointer to a PALETTEENTRY structure. This should be NULL in your case. (maybe)

CONST RECT *pDestRect: A pointer to a RECT structure that represents the destination rectangle for your picture. NULL for the whole surface.

LPCVOID pSrcData: This is a pointer to the 'file in memory.' This should be lpbi from above.

UINT SrcData: This is the size of your 'file in memory' in bytes. You should probably use the sizeof keyword. eg: sizeof(&lpbi).

CONST RECT *pSrcRect: This is a pointer to a RECT structure that represents the source rectangle for your picture. NULL if you want the entire picture.

DWORD Filter: This is the filtering method for the picture. You should probably use D3DX_DEFAULT as the value.

D3DCOLOR ColorKey: This is the transparency colour that you want to set. Use the value 0 (black) for disabling it.

D3DXIMAGE_INFO *pSrcInfo: This is a pointer to a D3DXIMAGE_INFO structure. Unless you actually need this use NULL as a value.

Then draw the surface to the screen or whatever and remember to check it that the loading of the file from memory was successful.

Also here is a link to an article on Gamedev: link

Good luck with your project.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this