Jump to content
  • Advertisement
Sign in to follow this  
iddqd42

DIB to Direct3d Texture

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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);
}

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!