Advertisement

Texturloading Problem

Started by April 19, 2002 02:29 PM
-1 comments, last by Austrian Coder 22 years, 10 months ago
Hi! I have here a nice lib. Then i have make a Texutreloader for bmps. When I put it direct into an exe and not in a lib then all went ok. But in the lib i get an Access Violation And i dont know why. unsigned char *expTextureManager::LoadBitmapFile (const char *filename, int &nWidth, int &nHeight, int &nBPP) { FILE *File; expBMPFILEHEADER fileHeader; expBMPINFOHEADER infoHeader; // unsigned int l_iImageSize; unsigned char tempRGB; // unsigned int i; unsigned char *pImage; // open filename in "read binary" mode File = fopen(filename, "rb"); if (File == 0) { Log.WriteLog (" Image-Error: File %s not found!", filename); return 0; } // header fread (&fileHeader, sizeof (fileHeader), 1, File); if (fileHeader.usType != ''MB'') { Log.WriteLog (" Image-Error: File %s is not a valid Bitmap!", filename); fclose (File); return 0; } // infos fread (&infoHeader, sizeof (infoHeader), 1, File); if (!CheckSize (infoHeader.lWidth) || !CheckSize (infoHeader.lHeight )) { Log.WriteLog (" Image-Error: Improper Dimension"); fclose (File); return 0; } fseek (File, fileHeader.uiOffBits , SEEK_SET); pImage = new unsigned char [fileHeader.uiSize]; if (!pImage) { delete [] pImage; Log.WriteLog (" Image-Error: Out Of Memory!"); fclose (File); return 0; } // Load Texture fread (pImage, 1, infoHeader.uiSizeImage, File); // Turn BGR to RBG // for (int i = 0; i < (int) infoHeader.uiSizeImage; i += 3) { // tempRGB = pImage ; // pImage = pImage ; // pImage = tempRGB; // } nWidth = infoHeader.lWidth ; nHeight = infoHeader.lHeight; nBPP = 3; // Only load 24-bit Bitmaps return pImage; <– Error } Thanks, Austrian Coder </i>

This topic is closed to new replies.

Advertisement