android–bitmap.compress破坏图片质量

android–bitmap.compress破坏图片质量,第1张

概述我正在使用应用程序获取gps位置并将其绘制为位图上的圆圈,然后将其保存以继续,因此我需要重复读取并保存文件.但不幸的是,当我保存文件并读取它时,文件在一些迭代后被损坏了……!代码:Fileoutput=newFile(tmpDirectory,"map.jpg");try{OutputStreamoutputStre

我正在使用应用程序获取gps位置并将其绘制为位图上的圆圈,然后将其保存以继续,因此我需要重复读取并保存文件.但不幸的是,当我保存文件并读取它时,文件在一些迭代后被损坏了……!代码:

file output = new file(tmpDirectory, "map.jpg");    try {        OutputStream outputStream = new fileOutputStream(output);        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);        outputStream.flush();        outputStream.close();    } catch (Exception ex) {        Message("error!");    }    directory = tmpDirectory;//updating directory to load the manipulated image    readfile(directory + "map.jpg", false);//setting the image vIEw new image

包含的图像:picture after iterations
图像包括:
main image

解决方法:

JPEG使用有损压缩.这意味着每次迭代都会失去一些质量.如果你想保留它,你应该使用像PNG这样的无丢失格式.

bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
总结

以上是内存溢出为你收集整理的android – bitmap.compress破坏图片质量全部内容,希望文章能够帮你解决android – bitmap.compress破坏图片质量所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1108686.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存