Jump to content
  • Advertisement


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

Lode Runner

BMP Texture problem

This topic is 6017 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. Im trying to Load a BMP file and turn it into a texture, i dont realy know what im doing anyway when i map the texture to a polygon all that shows up are 1 pixel in the lowerleft corner. heres some code:



int CreateTexture(char *Filename)
	HANDLE hFile;

	unsigned char *ImageBuffer;
	unsigned char tempRGB;
	unsigned int texture;

	unsigned long BytesRead;

	int width;
	int height;
	int bpp;
	if(hFile == INVALID_HANDLE_VALUE) MessageBox(NULL,"Could not open file","error",MB_OK);


	width  = InfoHeader.biWidth;
	height = InfoHeader.biHeight;
	bpp    = InfoHeader.biBitCount;

	ImageBuffer = new unsigned char[width*height*bpp/8];


	for (int loop = 0; loop < sizeof(ImageBuffer); loop+=3)
		tempRGB = ImageBuffer[loop];
		ImageBuffer[loop] = ImageBuffer[loop + 2];
		ImageBuffer[loop + 2] = tempRGB;



	delete [] ImageBuffer;
	return texture;
this code may be dead wrong,if so i hope you guys tell me thanks in advance Edited by - Lode Runner on January 28, 2002 11:28:55 PM Edited by - Lode Runner on January 28, 2002 11:31:23 PM

Share this post

Link to post
Share on other sites
1 - You can''t use sizeof to determine the size of an array. You will need to store the size in a int and use that number. The current code probably only reads 4 bytes, hence the single pixel.

2 - Bitmaps come in several different flavors. You need to make sure you are only using one kind or check for the correct version. I assume you are only using 24bpp, but make sure.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!