I need a function to invert the picture. The inverting the picture means you rev
ID: 3545799 • Letter: I
Question
I need a function to invert the picture. The inverting the picture means you reverse all the pixel colors. Eg: Like Color(R-255, G-255, B-255). It is my C++ homework. I tried to solved it but stop by how to check that image's color then invert color. I think that I should create two for loops like
for(x=1, x<801, ++x){
for(y=1, y<801, ++y){
putpixel(x, y,COLOR(R-255, G-255, B-255));}}
But there is a problem that it is the putpixel function does not check my image. Could someone tell me how to solve this problem please?
Assume I already have saveimage() and loadimage()function to save and load in memory and putpixe(x, y, color(R, G, B) for draw.
If you need more details plase comment there.
By the way, I do not need a complete design, just this one function
Explanation / Answer
You can get the width and height before the loop then
use for (x = 1 ; x < width; x++)
for Y = 1; y < height; y++)
BTW, I think invert color should be 255- R, not R-255, because 255 is the max value
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.