   BMP Loading Troubles
  I'm trying to load a bitmap image fir use as a heightfield, but keep getting the following errors when I try to compile:C:\Documents and Settings\Joe Teague\My Documents\GL\GLLandHM.cpp(48) : error C2501: 'imgData' : missing storage-class or type specifiersC:\Documents and Settings\Joe Teague\My Documents\GL\GLLandHM.cpp(48) : error C2040: 'imgData' : 'int' differs in levels of indirection from 'unsigned char *'The only problem is, imgData is declared, and exactly how it needs to be at that (as unsigned char *imgData).Thanks in advance   -- Joe TeagueEDIT: Hold on, forgot to include my code. The function call is:imgData = *LoadBMPForData("Data/Land/Land1.bmp", &bitmapInfoHeader);whereas the function is as follows:// Used to load a .BMP for data processing, no texturing (except maybe in height fields)unsigned char *LoadBMPForData (char *filename, BITMAPINFOHEADER *bitmapInfoHeader){FILE *file;// The file pointerBITMAPFILEHEADER bitmapFileHeader;// File headerunsigned char*   bitmapImage;// The image dataint imgIdx = 0;// Image index counterunsigned char    tempRGB;// Swap variable (to convert BGR to RGB)// Open the file in "binary read mode"file = fopen(filename, "rb");if (file == NULL){return NULL;}// Read the file headerfread(&bitmapInfoHeader, sizeof(BITMAPFILEHEADER), 1, file);// Verify that the file is a bitmap by checking against the universal headerfseek(file, bitmapFileHeader.bfOffBits, SEEK_SET);// Allocate memory for itbitmapImage = (unsigned char *)malloc(bitmapInfoHeader->biSizeImage);// Verify allocationif (!bitmapImage){free(bitmapImage);fclose(file);return NULL;}// Read the bitmap image datafread(bitmapImage, 1, bitmapInfoHeader->biSizeImage, file);// Make sure the data was readif (bitmapImage == NULL){fclose (file);return NULL;}// Swap R and B values to get the universal RGB, since bitmaps are by default in BGRfor (imgIdx = 0; imgIdx < bitmapInfoHeader->biSizeImage; imgIdx += 3){tempRGB= bitmapImage[imgIdx];bitmapImage[imgIdx]= bitmapImage[imgIdx + 2];bitmapImage[imgIdx + 2] = tempRGB;}// Close the file and store the datafclose (file);return bitmapImage;}[edited by - JTMoney55589 on August 1, 2003 5:57:14 PM]
  Well first of all imgData = *LoadBMPForData(...);should be changed toimgData = LoadBMPForData(...);... but you''ll probably get error message on that when handled the current error messages... anyway why don''t you include the declaration code too? ;  well, i dont know why i left the * in on my function call, but it actually gave me fewer errors that way, even though i know it's wrong. :-D. I honestly cannot figure out what the problem is. Knowing that everything is the same, here is all the info for the function:Declaration: unsigned char *LoadBMPForData (char *filename, BITMAPINFOHEADER *bitmapInfoHeader)Prototype (in the .h file): unsigned char *LoadBMPForData (char *filename, BITMAPINFOHEADER *bitmapInfoHeader);Call: imgData = LoadBMPForData("Data/Land/Land1.bmp", &bitmapInfoHeader);Yes, imgData is unsigned char *imgData.Thanks  Oh, BTW, the new errors are:c:\documents and settings\joe teague\my documents\gl\gllandhm.cpp(49) : error C2501: 'imgData' : missing storage-class or type specifiersc:\documents and settings\joe teague\my documents\gl\gllandhm.cpp(49) : error C2040: 'imgData' : 'int' differs in levels of indirection from 'unsigned char *'c:\documents and settings\joe teague\my documents\gl\gllandhm.cpp(49) : error C2440: 'initializing' : cannot convert from 'unsigned char *' to 'int'   This conversion requires a reinterpret_cast, a C-style cast or function-style cast -- Joe Teague   [edited by - jtmoney55589 on August 1, 2003 12:26:57 AM] [edited by - jtmoney55589 on August 1, 2003 12:54:03 AM];  try this:unsigned char *imgData = LoadBMPForData("Data/Land/Land1.bmp", &bitmapInfoHeader);   [edited by - 666_1337 on August 2, 2003 5:08:49 AM];  I'll be damned. Worked like a charm. Technically, what was the problem I was having? The pointer didn't point to anything when I declared it so I had to give it a value at the time of declaration? Whatever it was, thanks a million. EDIT: Whoops, looks like I spoke a bit too soon there. It compiles just fine now, but when I try to run it it gives me a "Driver component size mismatch" error. Anyone know what that means and how to fix it? -- Joe Teague   [edited by - jtmoney55589 on August 2, 2003 11:24:15 AM];quote:Original post by JTMoney55589   I'll be damned. Worked like a charm. Technically, what was the problem I was having? The pointer didn't point to anything when I declared it so I had to give it a value at the time of declaration? Whatever it was, thanks a million. yes. that is because the C standard asumes int if you don't give a data type.so:a;is equal toint a;main()is equal to "int main()"and:imgData = LoadBMPForData("Data/Land/Land1.bmp", &bitmapInfoHeader);is:int imgData = (unsigned char*)LoadBMPForData("Data/Land/Land1.bmp", &bitmapInfoHeader);what doesn't make any sence. int cannot be of type "unsigned char*":C:\Documents and Settings\Joe Teague\My Documents\GL\GLLandHM.cpp(48) : error C2040: 'imgData' : 'int' differs in levels of indirection from 'unsigned char *'quote:Original post by JTMoney55589   EDIT: Whoops, looks like I spoke a bit too soon there. It compiles just fine now, but when I try to run it it gives me a "Driver component size mismatch" error. Anyone know what that means and how to fix it?reinstalling the (or a  newer) driver might work...or maybe even rebooting... [edited by - 666_1337 on August 2, 2003 12:48:34 PM];  I downloaded and installed the latest nVidia driver and now everything works just fine. Thanks a bunch.   -- Joe Teague   [edited by - jtmoney55589 on August 2, 2003 5:34:14 PM]