Has anyone had any experiance loading a BCB6 TBitmap onto a DirectDraw Surface? At the moment, I'm just grabing the TBitmap's HDC, then blting it onto the surface, but nothing is actually copied...any ideas?
DW
Has anyone had any experiance loading a BCB6 TBitmap onto a DirectDraw Surface? At the moment, I'm just grabing the TBitmap's HDC, then blting it onto the surface, but nothing is actually copied...any ideas?
DW
Yeah don't use it.
Use the D3DX library for DirectX 9.0 to load the bitmap. DirectDraw is deprecated and as such you should not use it. Direct3D and DirectDraw have been merged into DirectGraphics.
Here is a simple texture loader in DirectX 9.0.
This function natively supports several popular image formats as well as DDS files.Code:#include "d3dx9.h" void LoadTexture(IDirect3DDevice9 *_Device,std::string _File,IDirect3DTexture9 *_Texture) { if (D3DXCreateTextureFromFile(_Device,_File,&_Texture))) { ::MessageBox(0,"Failed to load texture",0,0); } }
Bubba is correct. D3DX is a good library for loading bitmaps.
Just one change though:
Code:if (D3DXCreateTextureFromFile(_Device,_File.c_str(),&_Texture)))
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
any way to get this to work with DirectDraw?
The way you are doing it works does it not. Get a pointer to the surface, retrieve the data from TBitmap, copy the data to the surface via the pointer.
1. Retrieve from TBitmap, or get a pointer to TBitmap surface/data.
2. Lock DirectDraw surfaceand get pointer to surface.
3. Read from TBitmap, write to surface.
I tried that...didn't work to well...Noting gets copied.
I got the hDC for the DD7 surface, blted the bitmap to the DD7 surface, but nothing got coppied....Just gave up on it now, and will try somthing else