faraz_majidkhan
Broken In
Can Anyone tell me about a software that can show me the jpeg & bmp format files in text form like header info, pixels as RGB values(232,122,63),etc.
#define BYTE unsigned char
#define WORD unsigned int
#define DWORD unsigned long
/*STRUCTURE OF BITMAP FILE HEADER*/
/* FILE HEADER */
struct fileheader {
char bftype[2];
DWORD bfsize;
WORD bfreserved1;
WORD bfreserved2;
DWORD bfoffbits;
};
/* IMAGE INFORMATION HEADER */
struct bitmapinfoheader {
DWORD bisize;
DWORD biwidth;
DWORD biheight;
WORD biplanes;
WORD bibitcount;
DWORD bicompression;
DWORD bisizeimage;
DWORD bixpelspermeter;
DWORD biypelspermeter;
DWORD biclrused;
DWORD biclrimportant;
};
/* PALETTE HEADER*/
struct colortable {
BYTE rgbblue;
BYTE rgbgreen;
BYTE rgbred;
BYTE rgbreserved;
};
void displayBMPInfo(FILE *fp) {
unsigned long size;
struct fileheader header;
struct bitmapinfoheader info;
//struct colortable table;
//struct palettetype pal;
/*TO CHECK THE EXISTENCE OF FILE */
if(fp==NULL) {
return;
}
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
fread(&header, 1, sizeof(header), fp);
clrscr();
/* TO CHECK THE SIGNATURE OF THE BITMAP FILE "BM" */
if(header.bftype[0]!='B' || header.bftype[1]!='M') {
return;
}
fread(&info,1,sizeof(info),fp);
//if required the following BMP header informations can be displayed
printf("\n\t\t\tBITMAP FILE HEADER");
printf("\nSIZE= %d", size);
printf("\nBMPFILE's SIGNATURE= %c",header.bftype[0]);
printf("%c",header.bftype[1]);
printf("\nSIZE OF BITMAPFILE= %ld",header.bfsize);
printf("\nRESERVED1 = %d",header.bfreserved1);
printf("\nRESERVED2 = %d",header.bfreserved2);
printf("\nOFFSET TO THE IMAGE DATA = %ld",header.bfoffbits);
printf("\n\n\t\t\tBITMAP INFO HEADER");
printf("\n\nBITMAPINFO HEADER SIZE\t\t\t= %ld",info.bisize);
printf("\nIMAGE WIDTH\t\t\t\t= %ld",info.biwidth);
printf("\nIMAGE HEIGHT\t\t\t\t= %ld",info.biheight);
printf("\nNo. OF PLANES IN THE IMAGE\t\t= %d (usually '1')",info.biplanes);
printf("\nBITS REQUIRED TO REPRESENT A PIXEL\t= %d",info.bibitcount);
printf("\nCOMPRESSION BIT\t\t\t\t= %ld (0 -if no Compression used)",info.bicompression);
printf("\nBYTES REQUIRED FOR IMAGE DATA ALONE\t= %ld",info.bisizeimage);
printf("\nbixpelspermeter\t\t\t\t= %ld",info.bixpelspermeter);
printf("\nbiypelspermeter\t\t\t\t= %ld",info.biypelspermeter);
printf("\nNo. OF COLORS USED\t\t\t= %ld",info.biclrused);
printf("\nCOLOR IMPORTANT\t\t\t\t= %ld",info.biclrimportant);
}