2012-05-12 88 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