So the struct of the bitmap is like this, and I'm not sure how to get height and width if I don't read specifics in the header.
Code:
typedef struct {
char* data;
char* header;
int height;
int width;
int size;
} Bitmap;
Here is what I have so for for readImage, I'm not sure if I'm tracking the size correctly or freading correctly, I looked at the man page but it's still confusing.
Code:
void readImage(char* infile, Bitmap *bitmap){
int i;
FILE* input = fopen(infile, "rb");
char* array = malloc(sizeof(n)); /*n is defined earlier to be 10000*/
for(i=0; i<n; i++){
fread(&array[i], 1, 1, input);
bitmap->size +=1;
if((bitmap->size)==n){
array = realloc(array, (2*n)); /*I'm supposed to double if n isn't enought*/
}
}
bitmap->header = &array[0];
bitmap->data = &array[54];
fclose(input);
}