试图调整存储在我的SD卡上的图像大小,我注意到原来的颜色被改变了。它接缝BitmapFactory.decodeFile是可以响应的。这里是一个演示代码:Android不尊重色彩!
private void testImage() throws Exception{
BitmapFactory.Options o = new BitmapFactory.Options();
o.inDither = false;
o.inPreferredConfig = Bitmap.Config.ARGB_8888;
o.inScaled = false;
Bitmap b = BitmapFactory.decodeFile("/sdcard/test/original.jpg", o);
b.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream("/sdcard/test/result.jpg"));
b.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream("/sdcard/test/result.png"));
}
所得的图象(original.jpg,result.jpg,result.png):
已经可以看到,男孩的皮肤在2个结果图像上有点绿色。任何提示解决这个问题?
FWIW,这三个图像看起来和我完全一样。 – CommonsWare 2010-12-15 15:21:14
我真的没有看到你的png – schwiz 2010-12-15 15:22:09
FWIW有什么不同,我看到第二个和第一个相比有所不同:) – 2010-12-15 15:35:59