gpt4 book ai didi

java - 在 Android 中保存 JPEG 文件而不丢失像素信息

转载 作者:行者123 更新时间:2023-11-29 08:09:22 25 4
gpt4 key购买 nike

我正在通过 BitmapFactory 加载一个 jpeg 文件并尝试再次保存它(稍后我想在再次保存之前对像素数据进行一些计算)。

但是如果我尝试用

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

那么结果就和原图不完全一样了。一些像素有不同的颜色值,这对我以后的计算没有用。

是否可以无损地保护它?或者当我用

加载图片时已经出现问题了
Bitmap originalImage = BitmapFactory.decodeFile("/sdcard/input.jpg");

几行之前?

最佳答案

Is there a possibility to safe it lossless?

没有。 JPEG 格式使用有损压缩。即使您将质量设置为 100,它也不提供正式保证。

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

不,位图是……位图,即它们表示图像数据的确切位。

关于java - 在 Android 中保存 JPEG 文件而不丢失像素信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9195937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com