今天老师想让我帮忙把她们200多张寸照换成白底的,这些寸照里面多为蓝色底,红色底。
用ps?不!用java!!
对,我第一反应就是用java,到网上找到了一个获得图片像素的源码。动手改了下,就编出来了,200多张照片的处理就用了半分钟。
public class ImageColorDemo {
public static void main(String args[]) throws IOException {
File dir = new File("d:/d4");
File[] files = dir.listFiles();
for(int x=0;x> 16;
rgb[1] = (pixel & 0xff00) >> 8;
rgb[2] = (pixel & 0xff);
if(rgb[0]<155&&rgb[0]>0 && rgb[1]<256&&rgb[1]>105 && rgb[2]<256&&rgb[2]>105 ){
bi.setRGB(i, j, 0xffffff);
}
}
}
System.out.println("t处理完毕:"+files[x].getName());
System.out.println();
FileOutputStream ops = new FileOutputStream(new File("d:/d5/"+x+".jpg"));
ImageIO.write(bi,"jpg", ops);
ops.flush();
ops.close();
}
}
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



