/*BMP Attributes.C*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<graphics.h>
typedef struct bmp_header {
unsigned char ft[2];
unsigned long fsz;
unsigned int res1, res2;
unsigned long ofb, sz, wd, ht;
unsigned int npi, bpp;
unsigned long cps, isz, xres, yres;
unsigned long clru, clrimp;
}TH;
TH *ihdr;
typedef struct RGBtag {
unsigned char blue, red, green, resv;
}RGB;
RGB clrs[256], pal[256];
char buff[18];
void main()
{
int d= DETECT, m= VGAHI, xsize, ysize, pix, n, m1;
long int i, j;
FILE *imgf;
imgf= fopen("2.bmp", "rb");
if(imgf == NULL)
{
printf("\n\a ERROR");
exit(0);
}
clrscr();
fread(ihdr, sizeof(TH), 1, imgf);
printf("\n\t BMP FILE HEADER\n");
printf("\n1File Type: %c%c",ihdr->ft[0],ihdr->ft[1]);
printf("\n2 FILE SIZE = %ld bytes", ihdr -> fsz);
printf("\n3 RESERVED1 = %d ",ihdr -> res1);
printf("\n4 RESERVED2= %d ", ihdr-> res2);
printf("\n5 OFFSET TO START OF IMAGE= %ld bytes", ihdr->ofb);
printf("\n6 SIZE OF BITMAP INFO HEADER = %ld", ihdr->sz);
printf("\n7 IMAGE WIDTH = %ld pixels", ihdr->wd);
printf("\n8 IMAGE HEIGHT = %ld pixels ", ihdr->ht);
printf("\n9 no. of PLANES IN IMAGE = %d ", ihdr->npi);
printf("\n10 no of bits/ pixels= %d ", ihdr->bpp);
printf("\n11 TYPE OF COMPRESSION =%d", ihdr->cps);
printf("\n12 IMAGE SIZE= %ld bytes",ihdr->isz );
printf("\n13 HORIZONTAL RESOLUTION =%ld pixels/mtr", ihdr->xres);
printf("\n14 VERTICAL RESOLUTION = %ld pixel/mtr", ihdr->yres);
printf("\n15 NO of colours in image= %d", ihdr->clru);
printf("\n16 NO fo important colors %d ", ihdr->clrimp);
printf("\n RGB Values of a perticular pixel : \n\n");
printf("Row ?= ");
scanf("%d",&n);
printf("Column ?= ");
scanf("%d", &m1);
printf("\n ROW %d \n ",n);
printf("\n col. %d ", m1);
fseek(imgf, (n*sizeof(clrs))+(m1*sizeof(clrs)), SEEK_SET);
printf("\n R G B Resv. \n");
fread(&clrs, sizeof(clrs), 1, imgf);
printf("\n %d %d %d", clrs->blue, clrs-> green , clrs->resv);
getch();
}
OUTPUT:
BMP FILE HEADER
1File Type: BM
2 FILE SIZE = 25870 bytes
3 RESERVED1 = 0
4 RESERVED2= 0
5 OFFSET TO START OF IMAGE= 118 bytes
6 SIZE OF BITMAP INFO HEADER = 40
7 IMAGE WIDTH = 228 pixels
8 IMAGE HEIGHT = 222 pixels
9 no. of PLANES IN IMAGE = 1
10 no of bits/ pixels= 4
11 TYPE OF COMPRESSION =0
12 IMAGE SIZE= 25752 bytes
13 HORIZONTAL RESOLUTION =0 pixels/mtr
14 VERTICAL RESOLUTION = 0 pixel/mtr
15 NO of colours in image= 0
16 NO fo important colors 0
RGB Values of a perticular pixel :
Row ?= 2
Column ?=3
ROW 2
col. 3
R G B Resv.
136 135 119
Original Image (C:\TC\2.BMP)
Keine Kommentare:
Kommentar veröffentlichen