I am trying to flip a gray scale image horizontally. Pointer fp is pointing to original image and pointer fp1 is creating horizontally flipped image. The Program is executing properly but the output image is worst…
for( i =0 ;i<width ; i++)
for(j=0; j <height; j++)
idata[i][height - 1 -j] = ( (unsigned char)fgetc(fp));
//flipping image
for( i =0 ;i<width ; i++)
for(j=0; j <height; j++)
putc(idata[i][j] , fp1);
there is no problem in header copy of image. i think problem is residing in for loop… plz help me out
Are you sure you are not mixing up width and height? The code seems to assume that the data is read in a column wise order when it most likely is in a row wise order. Try flipping the for loops and the dimension for flipping, like so: