【发布时间】:2013-05-20 16:13:22
【问题描述】:
我已将位图图像转换为字符串以保存它:
............
Bitmap photo = extras.getParcelable("data");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
String encodedImage = Base64.encodeToString(b, Base64.DEFAULT);
然后我从字符串中检索位图来设置活动的背景,就像这样:
byte[] temp = Base64.decode(encodedImage, Base64.DEFAULT);
Options options = new BitmapFactory.Options();
options.inScaled = false;
Bitmap bitmap = BitmapFactory.decodeByteArray(temp, 0,
temp.length, options);
Drawable d = new BitmapDrawable(getResources(), bitmap);
getWindow().setBackgroundDrawable(d);
一切正常,但图像质量大大降低。如何保持图像质量与原始图像相同?我在这里做错了什么降低了质量吗?
【问题讨论】:
-
如果对您有帮助,请检查答案是否正确,以帮助其他有同样问题的人
标签: android bitmap bitmapfactory