This site requires JavaScript, please enable it in your browser!
Greenfoot back
Westga2016
Westga2016 wrote ...

2013/12/9

Increase Red Value Pixel

Westga2016 Westga2016

2013/12/9

#
Hello All. I am having problems with increasing the red value of the pixels by 30% with a maxium color value of 255. When I call the method nothing changes at all. I have posted my code i used below: Pixel myPix = getPixel(0); double newRedValue = myPix.getRed() * 0.30; myPix.setColor(255, myPix.getGreen(), myPix.getBlue());
danpost danpost

2013/12/9

#
Would help if '255' in your last line was changed to 'newRed' and your second line was replaced with
int oldRed = myPix.getRed();
int newRed = oldRed + (255-oldRed)*3/10;
This should increase the red value 30 percent of the difference toward 255. Meaning the closer to 255 the value starts, the less of an increase it will receive. I coded it this way because using 'oldRed*13/10', which would increase 'oldRed' by 30 percent could result in values greater than 255; although you could check the value of it and set the value to 255 if the result was over it.
Westga2016 Westga2016

2013/12/9

#
That kinda of help Danpost I'm working on an greenfoot slideshow. I was trying to look at your Fractal Slideshow as a aide but i am still lost. i wish there was a way for me to upload the file and so you can tell me what i am doing wrong
You need to login to post a reply.