Forum Discussion
Altera_Forum
Honored Contributor
20 years agoHow to store a BMP file to nios board from a PC
Hi I am using the Apex20kE device I got a problem to load a bmp file to the Nios development board. Here is my code # include <stdio.h># include <nios.h> # define K 12960 mai...
Altera_Forum
Honored Contributor
20 years agoI'm assuming K is the size of the file you want to read so you could try:
fread(p, 1, K, fp); which reads K "items" of size 1 byte. fread returns the number of items read so you can test whether it worked like this: numRead =fread(p,1,K,fp); if (numRead != K) printf("read only %d of %d\n", numRead, K); The reason you cannot use fgets is that that function stops when it encounters a newline in the data. By the way, you can look at the Windows structures BITMAPFILEHEADER and BITMAPINFO to find a way of properly parsing out a bitmap. Andrew