Jump to content
  • Advertisement
Sign in to follow this  

Strange end of file error

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

I currently writing a function that's supposed to draw a BMP file (24bit per color) on the screen.


        FILE *f;
	BITMAPFILEHEADER bitmapfileheader;
	BITMAPINFOHEADER bitmapinfoheader;
	int i, x, y;
	char c[3];

//	t = (Texture*) malloc(sizeof(Texture));

	f=fopen(File...., "r");

	fread(&bitmapfileheader, sizeof(BITMAPFILEHEADER), 1, f);
	fread(&bitmapinfoheader, sizeof(BITMAPINFOHEADER), 1, f);

	HDC	hdc;
	hdc = GetDC(mHwnd);

	for (y=0;y<bitmapinfoheader.biHeight;y++)
		for (x=0;x<bitmapinfoheader.biWidth;x++)
			fread(c, sizeof(char), 3, f);
			SetPixel(hdc, int(x), int(y), RGB(c[0],c[1],c[2]));

According to bitmapfileheader.bfSize the file is 1440056 byte large Yet i can only read aprox. 16686 bytes. Anyone know what i'm doing wrong??

Share this post

Link to post
Share on other sites
First thing, if it's a bitmap file, you should open it with f=fopen(filename, "rb");

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!