【发布时间】:2024-06-22 09:50:01
【问题描述】:
今天我去学校把这件事给我的老师看,但他不理解,也很惊讶。
对于“1.jpg”,首先我将红色、绿色、蓝色值向右移动并打印这些值。在我向左移动所有这些值之后,并在创建新图片之后。“2.jpg”(所以相同的图片)
最后我看两张图片并比较它们。这些看起来彼此相似,但它们并不相同。我检查了这些比较。
public static void main(String[] args) {
BufferedImage resim=null;
File f=null;
try {
f=new File("C:\\Users\\burak\\Desktop\\javaresim\\1.jpg");
resim=ImageIO.read(f);
} catch (Exception e) {
e.printStackTrace();
}
yük=resim.getHeight();
gen=resim.getWidth();
boyut=(gen*yük);
for(int i=0;i<gen;i++){
for(int j=0;j<yük;j++){
int p=resim.getRGB(i, j);
int a=(p&0xff000000)>>24;
int r=(p&0x00ff0000)>>16;
int g=(p&0x0000ff00)>>8;
int b=p&0x0000000ff;
System.out.print(r+" ");
p=(a<<24)|(r<<16)|(g<<8)|b;
resim.setRGB(i, j, p);
}
}
try{
f=new File("C:\\Users\\burak\\Desktop\\javaresim\\2.jpg");
ImageIO.write(resim, "jpg", f);
}catch(Exception e){
e.printStackTrace();
}
}
}
【问题讨论】:
标签: java image jpeg rgb bufferedimage