DIB to Direct3d Texture

Started by
2 comments, last by Endurion 18 years, 4 months ago
Hi, im reading all frames from a AVI and now ide like to create a texture from them, so that the small movie can be put on a quad or whatever. I have a pointer pointing at all the frame data using CreateDIBSection, however, i cant seem to make a texture out of it, according to msdn, in order to use D3DXCreateTextureFromFileInMemory i would have to have a complete bitmap in the memory not just its data. Do i have to compose a bitmap using the data or is there an easier way to do this? thanks a lot // iddqd.
The more you know, the more you know that you dont know.
Advertisement
If you know the format of the DIB section you can Lock the textures surface and copy the pixel data (line per line -> Pitch!) to the texture.

Make sure you've got corresponding formats or you have to convert the pixel data yourself.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Thanks a lot for the reply, and ya, i do know the format, its a 24bit bitmap.
This is what i currently have, it draws the bitmap (avi really), however it looks really bugged ;)

http://trelphin.net/temp/wierd.jpg

if(m_pTex == NULL)
device->CreateTexture(m_dwScaleWidth, m_dwScaleHeight, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pTex, NULL);

if(m_pTex)
{
m_pTex->LockRect(0, &rect, 0, 0);
memcpy(rect.pBits, pBitmapData, lpbi->biSizeImage);
m_pTex->UnlockRect(0);

device->SetTexture(0, m_pTex);
}
You have to copy the pixel data line per line!

On most textures there's a Pitch (offset from line to line in bytes). You get this Pitch value in the D3DLOCKED_RECT structure.

Also, D3DFMT_A8R8G8B8 is not suitable for a true 24 bit bitmap. The corresponding format would be D3DFMT_R8G8B8. If that is not available you have to modify the pixel data.

For a more thourough explanation look at neXe at GameDev".

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement