Negate and display the image
The code in Listing 6:
Listing 6. Negate and display the image.
//Cycle through the bitmap negating each pixel.
for(int row = 0;row < height;row++){
for(int column = 0;column < width;column++){
pixel = getpixel(picA,column,row);
red = getr(pixel);
green = getg(pixel);
blue = getb(pixel);
putpixel(picA,column,row,makecol(
255-red,255-green,255-blue));
}//end loop row
}//end loop on column
//Copy the modified bitmap to the onscreen window
// immediately below the original image.
blit(picA, screen, 0,0,0,height,width,height);
//Block and wait until the user presses a key.
readkey();
//Destroy bitmap to avoid memory leaks.
destroy_bitmap(picA);
return 0;//Return 0 to indicate a successful run.
}//end main function
END_OF_MAIN()
|