I am trying to learn image processing using c.
#include <stdio.h>
int main(){
FILE *streamIn;
streamIn=fopen("lena512.bmp","r");
//read imageHeader and colorTable
unsigned char header[54];//to store the image header
//unsigned char colorTable[1024];//to store the colorTable,if it exists
for(int i=0;i<54;i++){
header[i]=getc(streamIn);
}
/*
width of the image(18th byte)
height of the image(22nd byte)
bitDepth of the image(28th byte)
*/
int width=*(int*)(&header[18]);
int height=*(int*)(&header[22]);
int bitDepth=*(int*)(&header[28]);
}
I came across the line which i couldn't understand.
int width=*(int*)(&header[18]);
Why can't we simply do the type casting like int width=(int)(header[18]);?