问题:何时在 SD 卡上保存可绘制对象或位图?
我正在尝试将图像保存在 SD 卡中,如下所示:
Bitmap bitmap=Bitmap.createBitmap(400, 300, Bitmap.Config.ARGB_8888);
Canvas canvas=new Canvas(bitmap);
imageView.draw(canvas);
file = new File(folder, "temp.jpg");
try {
outStream = new FileOutputStream(file);
bitmapP.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
outStream.flush();
outStream.close();
return file.toString();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
现在我得到的图像如下所示:
Bitmap bitmap = BitmapFactory.decodeFile(image);
我有位图,但我的位图质量变得模糊...... 我做错了什么?
任何人都可以帮助我吗? 谢谢
I am trying to save image in sd card like as :
Bitmap bitmap=Bitmap.createBitmap(400, 300, Bitmap.Config.ARGB_8888);
Canvas canvas=new Canvas(bitmap);
imageView.draw(canvas);
file = new File(folder, "temp.jpg");
try {
outStream = new FileOutputStream(file);
bitmapP.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
outStream.flush();
outStream.close();
return file.toString();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
Now i get image like as:
Bitmap bitmap = BitmapFactory.decodeFile(image);
I got bitmap, But my bitmap quality is going blur...
What's i doing wrong ?
Any one can help me?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JPEG
不是无损格式。有点模糊是正常的。其他选项有 Bitmap.compressFormat.WEBP 和位图.压缩格式.PNGJPEG
is not a lossless format. It is normal that it gets blurred little bit. Other options are Bitmap.CompressFormat.WEBP & Bitmap.CompressFormat.PNG尝试从文件中获取位图,如下所示:
希望这会对您有所帮助!如果您还没有找到答案!
try to get bitmap from file like this:
hope this will help you! if you haven't already found an answer!