【发布时间】:2019-08-26 21:57:57
【问题描述】:
我需要为图片添加色调,然后将图片恢复为原始颜色。我可以添加色调,但不知道如何将图片恢复为原始颜色。
我想创建一个将图片重置为原始颜色的方法。
尝试
public void changeBlues(double param){
Pixel[] pixelArray = this.getPixels();
Pixel pixel = null;
int value = 0;
int index = 0;
if(param <= 0.0){
System.out.println("Error! Parameter less than or equal to 0.0");
return;
}
else if(param > 5.0){
System.out.println("Error! Paramater is greater than five.");
return;
}
//loop through all the pixels
//get the current pixel
while(index < (int)(pixelArray.length)){
if(param < 1.0){
pixel = pixelArray[index];
//get the value
value = pixel.getBlue();
// decrease the value by param
value = (int)((value - (value * param)));
// set he blue value of the current pixel to the new value
pixel.setBlue(value);
// increment the index
index = index + 1;
}
pixel = pixelArray[index];
//get the value
value = pixel.getBlue();
// decrease the value by param
value = (int)((value + (value * param)));
// set he blue value of the current pixel to the new value
pixel.setBlue(value);
// increment the index
index = index + 1;
}
}
【问题讨论】:
-
您需要维护原始数据的副本或生成增量,以便了解更改的内容和方式
-
我将如何维护原始数据的副本?