• Advertisement
Sign in to follow this  

Load Textures From File

This topic is 4921 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

I am a newbie at this, I know how to load a .bmp file, is there any way to load a gif or any other file format than can have transparent pixels?

Share this post


Link to post
Share on other sites
Advertisement
Look at the D3DXCreateTextureFromFile family of functions that ship with DirectX -- they provide a lot of this functionality for you.

If you want to write the loader yourself, TGA files can be pretty simple. The header for a TGA file looks like this:

typedef struct
{
BYTE identsize; // size of ID field that follows 18 byte header (0 usually)
BYTE colourmaptype; // type of colour map 0=none, 1=has palette
BYTE imagetype; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed

short colourmapstart; // first colour map entry in palette
short colourmaplength; // number of colours in palette
BYTE colourmapbits; // number of bits per palette entry 15,16,24,32

short xstart; // image x origin
short ystart; // image y origin
short width; // image width in pixels
short height; // image height in pixels
BYTE bits; // image bits per pixel 8,16,24,32
BYTE descriptor; // image descriptor bits (vh flip bits)

// pixel data follows header

} TGA_HEADER;


Hope this helps a little.

Edited by Coder: Source tags are almost always preferred, at least for the syntax highlighting. See GDNet Forums FAQ

[Edited by - Coder on August 3, 2004 4:36:09 PM]

Share this post


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

  • Advertisement