对Java图片处理的内容涉猎不深,言辞简陋望请见谅。
java实现色阶调整,即调整图片rgb分量,进而也可以调节图片亮度。
测试代码
public static void main(String[] args) {
//文件与BufferedImage间的转换
BufferedImage bi=file2img("test.jpg");
//读取图片
BufferedImage bii=img_color_gradation(bi,100,0,0);
img2file(bii,"jpg","test1.jpg");
//生成图片
}
色阶调整代码
//图片色阶调整,调整rgb的分量
public static BufferedImage img_color_gradation(BufferedImage imgsrc, int r, int g, int b) {
try {
//创建一个不带透明度的图片
BufferedImage back=new BufferedImage(imgsrc.getWidth(), imgsrc.getHeight(),BufferedImage.TYPE_INT_RGB);
int width = imgsrc.getWidth();
int height = imgsrc.getHeight();
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {