   Loading a TGA problem
  Hey. I'm trying to implement a TGA reader for my engine and I'm stuck right at the beginning.I have this code typedef unsigned char byte;   WORD width = 0, height = 0;byte length = 0;byte imageType = 0;byte bits = 0;FILE *pFile = NULL;int channels = 0;int stride = 0;int i = 0;if((pFile = fopen(strFileName, "rb")) == NULL) return NULL;pImageData = new CImage();fread(&length, sizeof(byte), 1, pFile);fread(&imageType, sizeof(byte), 1, pFile);fseek(pFile, 9, SEEK_CUR);fread(&width,  sizeof(WORD), 1, pFile);fread(&height, sizeof(WORD), 1, pFile);fread(&bits,   sizeof(byte), 1, pFile);fseek(pFile, length + 1, SEEK_CUR);  I don't get why all the variables are 0. I've done some testing in another language and aparently the first 2 bytes are 0 and then there is a 10. Reading all the file as bytes I've noticed that on the 13th byte is 128 then there is a 0 then again a 128 which is good because the width and height are 128. I don't get why the first bits are read wrong.Is there a problem with the way I declare my byte definition?   
  What operating system are you programming for? Is it Windows? If so, take a look at my TGA loader in my Development Journal.You may need to look at how type structures are 'packed'   ;  I've implemented a TGA loader which you can view on my website.  When I get home later tonight, I'll check out my code to see what you have that is different.  How did you generate your TGA file?   ;  Dunno about your problem with the TGA format and you'd be better off just making a struct, setting it to 1 byte packing, and reading the whole header in 1 call...Barring that, you said that the width starts at byte 13, then the height, etc.  But see, in the code you posted, you read 1 byte twice, and skip 9 with seek, which is 11 - not 13.  Could that be where you're getting confused?   ;  Before reading a format it is always a good idea to have the specification, grab yourself a version 2.0 copy from here.From the spec you can see that when you skip nine bytes you are actually then going to read in second byte of the y origin. After reading in the header you then skip "length + 1" why?   