now the bits per pixel(bpp) and plane are showing wrong in the code..
if i write the whole thing to another file will it be a bmp image or is there anything wrong with the code?
#include<stdio.h>
void main()
{
char ch[1000],offset[60];long int height;int width;long int size;int r1,r2;long int sz,a,a1,a2,a3,comp;int plane;int bpp1;
unsigned char blue,green,red;
FILE *fp=fopen("uu.bmp","r"),*fp1=fopen("aa","w");
fseek(fp,0,0);
fread(ch,2,1,fp);
fprintf(fp1,"%s\n",ch);
fseek(fp,2,0);
fread(&size,4,1,fp);
fprintf(fp1,"%ld\n",size);
fseek(fp,6,0);
fread(&r1,2,1,fp);
fprintf(fp1,"%d\n",r1);
fseek(fp,8,0);
fread(&r2,2,1,fp);
fprintf(fp1,"%d\n",r2);
fseek(fp,10,0);
fread(offset,4,1,fp);
fprintf(fp1,"%s\n",offset);
fseek(fp,14,0);
fread(&sz,4,1,fp);
fprintf(fp1,"%ld\n",sz);
fseek(fp,18,0);
fread(&height,4,1,fp);
fprintf(fp1,"%ld\n",height);
fseek(fp,22,0);
fread(&width,4,1,fp);
fprintf(fp1,"%d\n",width);
fseek(fp,26,0);
fread(&plane,2,1,fp);
fprintf(fp1,"%d\n",plane);
fseek(fp,28,0);
fread(&bpp1,2,1,fp);
fprintf(fp1,"%d\n",bpp1);
fseek(fp,30,0);
fread(&comp,4,1,fp);
fprintf(fp1,"%ld\n",comp);
fseek(fp,34,0);
fread(&a,4,1,fp);
fprintf(fp1,"%ld\n",a);
fseek(fp,38,0);
fread(&a1,4,1,fp);
fprintf(fp1,"%ld\n",a1);
fseek(fp,42,0);
fread(&a2,4,1,fp);
fprintf(fp1,"%ld\n",a2);
fseek(fp,46,0);
fread(&a3,4,1,fp);
fprintf(fp1,"%ld\n",a3);
printf("height=%d\nwidth=%d\nsize=%d\nreserved=%ld\tresered=%ld\nplane=%ld\nbpp=%d\n",height,width,size,r1,r2,plane,bpp1);
printf("SOI=%s",ch);
fseek(fp,54,0);
while(!feof(fp))
{
{
//fread(&p,sizeof(p),1,image);
fread(&blue,sizeof(unsigned char),1,fp);
fread(&green,sizeof(unsigned char),1,fp);
fread(&red,sizeof(unsigned char),1,fp);
//pic[i]=p;
//printf(" %u %u %u \n",blue,green,red);
fprintf(fp1,"%u %u %u\n",blue,green,red);
}
}
}

New Topic/Question
Reply



MultiQuote





|