/*Halve Images */
void halveImage( image full, image *half)
{
int r, c, p ;
/* construct an image structure of the appropriate size */
if ( !newImage( half, full.nrows/2, full.ncols/2 ) )
{
printf("halveImages(): newImage() failed\n" );
system( "pause" );
exit( EXIT_FAILURE );
}
for ( r=0; r<full.nrows; r+=2 )
for ( c=0; c<full.ncols; c+=2 )
{
p = getPixel( full, r, c ) ;
setPixel( *half, r/2, c/2, (unsigned char)p );
}
}
Comments: