【发布时间】:2013-09-13 16:04:24
【问题描述】:
嗯,我得到了这个.. 因为在我的地方他们这样要求它.. 嗯,我有这个: //一些变量和注释是可能的代码..但我的意思是我不知道该怎么做,我在互联网上发现转换R是字节在* 0.21中,G是* 0.71,我猜是蓝色是 * 0.07。我只能使用那个库 java.io.*;我正在使用 1024 x 768 的 BMP 格式图像,如果你能帮助我,或者你想让我更具体,请告诉我。我不知道我是否必须添加其他变量或取出一些变量或修改,请帮助我。我对这门语言不是很陌生,但我不是专家。代码就在这里:
导入 java.io.*;
公共类灰度{
FileInputStream image;
FileOutputStream img;
byte[] datos;
int i;
int cont;
public Grayscale(String nombre)throws Exception{
this.image = new FileInputStream(nombre);
this.img = img;
this.datos = new byte[image.available()];
this.i = 54;
this.cont = 1;
}
public void gray()throws Exception{
image.read(datos);
img = new FileOutputStream("grayscale.bmp");
while(i<datos.length){
if(cont == 1){
datos[i] = datos[i] ;//* 0.21;
cont++;
} else if(cont == 2){
datos[i] = datos [i] ;//* 0.71;
cont++;
} else if(cont == 3){
datos[i] = datos[i] ;//* 0.07;
cont++;
}else{
cont = 1;
}
i++;
}
img.write(datos);
}
}
【问题讨论】:
标签: java bitmapimage grayscale