try{
//이미지 호출 처리
BufferedImage originalImage = ImageIO.read(new File("rgb.jpg"));
ColorSpace rgbCS = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorSpace grayCS = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorConvertOp op = new ColorConvertOp(rgbCS, grayCS, null);
ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
int[] nBits = { 8 };
ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, nBits, false, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
WritableRaster raster = ccm.createCompatibleWritableRaster(mPhotoLayoutWidth, mPhotoLayoutHeight);
BufferedImage bufferedImage = new BufferedImage(ccm, raster, false, null);
try {
op.filter(originalImage, bufferedImage);
} catch (ProfileDataException ex) {
throw new RuntimeException("Test Failed", ex);
}
int[] pixels = new int[mPhotoLayoutWidth * mPhotoLayoutHeight];
bufferedImage.getRGB(0, 0, mPhotoLayoutWidth, mPhotoLayoutHeight, pixels, 0, mPhotoLayoutWidth);
int result = 0;
for (int h = 0; h < bufferedImage.getHeight(); h++ ){
for (int w = 0; w < bufferedImage.getWidth(); w++ ){
int argb = bufferedImage.getRGB(w,h);
int red = (argb >> 16) & 0xff;
int green = (argb >> 8) & 0xff;
int blue = (argb) & 0xff;
if(red > 0){
result = 229; //제거 168은 100으로 치환됨 / 대상 229는 200으로
}else{
result = 0;
}
Color col = new Color(result, result, result);
bufferedImage.setRGB(w, h, col.getRGB());
}
}
}catch(IOException e){
}
해당 자바 소스를 안드로이드용으로 만들고 싶은데, 엄청 헤매고 있습니다. ㅠㅜ
고수님들의 도움 부탁드립니다.
1.원본 rgb.jpg파일

2.결과물( gray one channel, 8Bit)
