2012-05-12 85 views
4

在我的应用程序中,绘制位图就好像颜色是较低质量的类型。如果我使用图库应用加载背景图片,它加载得很好,看起来不像是超低质量。我使用的加载和借鉴我的图片的代码很简单:Android位图质量问题

//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); 

如果没有代码告诉你什么是错的,我做了一个形象的比较什么形象实际上看起来像一台计算机或其他图像浏览器上,以及它在应用中的样子。 Top image is the app on the phone, bottom image is what the background image actually looks like. Notice the lines on the top image. What is up with that?

+0

坦白地说,大多数Android的图形输出是帕格废话,我不知道如果用户会抱怨.. – ina

+0

@ina也许这是废话,因为人们在他们的应用程序中接受半解决方案;)。 –

回答

5

问题有点类似Bad image quality after resizing/scaling bitmap

尝试禁用缩放,在屏幕外的位图调整,并确保位图是32位(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); 

另一个很好的和完整的答案约图像缩放/处理可以在Quality problems when resizing an image at runtime

+0

请告诉我什么是“a.getResources()”a =? –

+0

activity :: getResources() – goRGon

+1

即使这样,我仍然得到一个非常糟糕的结果... – slott