void copyImage( image source, image *copy ) { int r, c, value; /* construct an image structure of the appropriate size */ if ( !newImage( copy, source.nrows, source.ncols ) ) { printf("copyImage(): newImage failed\n" ); exit( EXIT_FAILURE ); } /* copy data from the old image to the new */ for ( r=0; r<source.nrows; r++ ) for ( c=0; c<source.ncols; c++ ) { value = getPixel( source, r, c ) ; setPixel( *copy, r, c, (unsigned char)value ); } }
Comments: