在 Android 中保存位图
我正在尝试为 Android 实现一个隐写术项目。我已经操纵了像素值并创建了一个新的位图。现在,当我使用 getPixels() 将位图存储到手机内存或存储卡中
//fo denotes File output Stream
Bitmap.compress(Bitmap.CompressFormat.JPEG,100,fo);
//OR
Bitmap.compress(Bitmap.CompressFormat.PNG,100,fo);
并尝试访问像素时;
这些值将恢复为原始位图,即而不是操作后的位图。 有人能弄清楚这是为什么吗?
I am trying to implement a Steganography project for Android. I have manipulated the pixel values and created a new bitmap. Now when i store the bitmap into the phone memory or memory card using
//fo denotes File output Stream
Bitmap.compress(Bitmap.CompressFormat.JPEG,100,fo);
//OR
Bitmap.compress(Bitmap.CompressFormat.PNG,100,fo);
and try accessing the pixels back using getPixels();
the values are reverted back to the original bitmap i.e. rather than the manipulated bitmap.
Can anybody figure why this is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这个答案 https://stackoverflow.com/a/7887114/964741
look at this answer https://stackoverflow.com/a/7887114/964741
JPEG 是有损的,压缩时会改变像素值。如果您想保留颜色,请使用 PNG。
JPEG is lossy, it can change pixel values when compressing. Use PNG if you want to preserve colors.