保存JPEG文件在Android中没有的像素信息丢失 [英] Saving JPEG files in Android with no loss of pixel information

查看:149
本文介绍了保存JPEG文件在Android中没有的像素信息丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加载通过BitmapFactory一个JPEG文件,并尝试重新保存(后来我想这样做的像素数据之前,我再次保存一些计算)。

但是,如果我尝试将其与保存

 的FileOutputStream FOS =新的FileOutputStream(新文件(/ SD卡/ test.jpg放在));
originalImage.com preSS(Bitmap.Com pressFormat.JPEG,100,FOS);

那么它是不完全一样的结果,作为原始图象。一些像素已经得到不同的颜色值,这不是北京时间有用我后来的计算。

有没有一种可能性,它安全无损?或者是问题已经当我加载的图片

 位图originalImage = BitmapFactory.de codeFILE(/ SD卡/ input.jpg);

几行过吗?


解决方案

  

有没有一种可能性,它安全无损?


没有。 JPEG格式使用有损COM pression。它使没有正式的保证,即使你设置的质量为100。


  

或有问题已经当我加载的图片[...]


没有,位图是...位图,即他们重新present的图像数据的确切位。

I'm loading a jpeg-file via BitmapFactory and try to save it again (later I want to do some calculation on the pixel data before I save it again).

But if I try to save it with

FileOutputStream fos = new FileOutputStream(new File("/sdcard/test.jpg"));
originalImage.compress(Bitmap.CompressFormat.JPEG, 100, fos);

then it is not exactly the same result as in the original picture. Some pixel have got different color values and this ist not useful for my later calculation.

Is there a possibility to safe it lossless? Or is the problem already when I load the picture with

Bitmap originalImage = BitmapFactory.decodeFile("/sdcard/input.jpg");

few lines before?

解决方案

Is there a possibility to safe it lossless?

No. The JPEG format uses a lossy compression. It makes no formal guarantees even if you set the quality to 100.

Or is the problem already when I load the picture with [...]

No, bitmaps are... maps of bits, i.e. they represent the exact bits of the image data.

这篇关于保存JPEG文件在Android中没有的像素信息丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆