Android的位图质量问题 [英] Android bitmap quality issues
问题描述
在我的应用程序,位图绘制,如果颜色是一些低质量的类型。如果我使用的库的应用程序加载的背景图片,它加载就好了,不会像它是超级低质量。在codeI正在使用加载和借鉴我的图片很简单:
In my app, the bitmap is drawn as if the color is some lower quality type. If i load up the background image using the gallery app, it loads just fine and does not look like it's super low quality. The code i am using to load and draw my images is simple:
//Code for initializing the Bitmap
Bitmap bitmap = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.none), (int) (canvas.getWidth() * compression), (int) (canvas.getHeight() * compression), true);
//...
//Code for drawing this Bitmap
canvas.drawBitmap(bitmap, null, new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), null);
如果没有在code告诉你什么是错的,我做了比较形象实际上看起来是什么样的计算机或其他图像浏览器,并且它看起来像在应用程序上的图像。
If nothing in the code tells you what is wrong, i made an image comparing what the image actually looks like on a computer or other image viewer, and what it looks like in the app.
推荐答案
问题有点类似<一个href="http://stackoverflow.com/questions/4821488/bad-image-quality-after-resizing-scaling-bitmap">Bad调整后的图像质量/缩放位
尝试禁用缩放,调整大小的屏幕外的位图,并确保该位图是32位(ARGB888):
try disabling scaling, resize in an offscreen bitmap and make sure that Bitmap is 32 bits (ARGB888):
Options options = new BitmapFactory.Options();
options.inScaled = false;
options.inDither = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap source = BitmapFactory.decodeResource(a.getResources(), path, options);
有关图像缩放另一个很好的和完整的答案/处理可以在<一个发现href="http://stackoverflow.com/questions/4231817/quality-problems-when-resizing-an-image-at-runtime">Quality调整问题在运行时图像时
这篇关于Android的位图质量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!