Sign in to follow this  
PrettySneaky

Strange end of file error

Recommended Posts

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

-----------FUNCTION----------------

        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]));
		}
	
	}
	Sleep(3000);
	PostQuitMessage(0);
	fclose(f);

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this