Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

why fread can't read .bmp image file properly?

$
0
0

I used fread to read .bmp image file into buffer based on code below:

//Open an Image File
pImageFile = fopen("D:\\SampleBitMap.bmp","rb");

//Get Image File Size
	fseek(pImageFile,0,SEEK_END);
	lSize =ftell(pImageFile);
	rewind(pImageFile);

	//Allocate memory to buffer
	bytevalue = (char*) malloc (sizeof(char)*lSize);

	fread(bytevalue,1,lSize,pImageFile);
	

	printf("bytevalue is %s \n",bytevalue);

no matter how many byte size per element or how many elements I set, the bytevalue is always equal to BM^ò

Is there anything wrong with my code?


Jason


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>