c - can't read bmp file perfectly -
i newbie in c ,i write c code reading bmp file of 2448x280 pixels having 32 bit depth , writing new bmp file. read pixels 1 one. reading header , problem after completing read , write operation on pixels, current position original image is= 2741814, right according me result image have position = 2903490. so, please tell me mistake. here code:-
#include<stdio.h> #include<conio.h> void main(void) { long int length; int count,r,c,p; file *image; file *result; char read_pixels; image=fopen("image.bmp","rb"); result=fopen("result.bmp","w+"); for(count=0;count<54;count++) { fread(&read_pixels,1,sizeof(read_pixels),image); fprintf(result,"%c",read_pixels); } for(c=0;c<280;c++) { for(r=0;r<2448;r++) { for(p=0;p<4;p++) { fread(&read_pixels,1,sizeof(read_pixels),image); fprintf(result,"%c",read_pixels); } } } fseek(image,0,seek_cur); length=ftell(image); printf("position of image after reading pixels =%d\n",length); fseek(result,0,seek_cur); length=ftell(result); printf("position of result after writing pixels=%d\n",length); fclose(image); fclose(result); getch(); }
Comments
Post a Comment