PDA

View Full Version : Load DDS into a surface



Faw
09-05-2006, 03:17 PM
I need a sample of how to load a DDS into a surface. Anyone has a sample on how to do this?

WILL
09-05-2006, 05:27 PM
You'll probably need to provide a little bit more information... ie. Whats a DDS? and What kind of surface you're using?

Faw
09-05-2006, 05:53 PM
DDS=Direct Draw Surface, the TDirectDrawSurface can only load normal image types defined in Delphi (BMP,JPG, etc...) but not DDS files.

Clootie
09-05-2006, 10:03 PM
As DDS is a acronim DirectDrawSurface - loading DDS in DirectX7 is pretty easy. Just lock surface and copy data from file to locked memory (assuming both surface and DDS file have the same format)

DDS File Reference on MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/dx9_graphics_reference_dds_file.asp)

Faw
09-05-2006, 11:28 PM
As DDS is a acronim DirectDrawSurface - loading DDS in DirectX7 is pretty easy. Just lock surface and copy data from file to locked memory (assuming both surface and DDS file have the same format)

DDS File Reference on MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/dx9_graphics_reference_dds_file.asp)

Ok, but how? I guess I have to read the DDS header to get the info and size of the data, right? That's why I asked for a sample, I have never worked with TDelphiX. Can't you give me a small sample.

What should I do, these steps (or it is easier than that)?
1. Read Header,
2. Set TDirectDrawSurface info to the one in the header? (width, height,..)
3. Lock
4. Do a memcopy from file to mem
5. Unlock?

Can I just load the file into memory, and do a CreateSurface(TDDSurfaceDesc_DX6(memory))?

Clootie
10-05-2006, 09:30 PM
I have not touched DelphiX code for a really long time, so can't answear on DelphiX specific bits...

You can
1) read whole file in memory
2) alias DDSURFACEDESC2 pointer to 5-th byte of this memory
3) gather needed info for creating DirectDraw surface; create it
4) do Move(file_in_mem, memory_of_locked_directdraw_surface)