• Advertisement

Archived

This topic is now archived and is closed to further replies.

Texturloading Problem

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

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 [i + 0] = pImage [i + 2]; // pImage [i + 2] = tempRGB; // } nWidth = infoHeader.lWidth ; nHeight = infoHeader.lHeight; nBPP = 3; // Only load 24-bit Bitmaps return pImage; <-- Error } Thanks, Austrian Coder

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement