2017-04-12 90 views
0

我在画布中绘制了我的游戏的background.png图像(图像比较高,因为是一个模仿背景)。这些图像有这样的尺寸:Android缩小图像当存在于可绘制文件夹中时

  • 绘制-xhdpi:1817x443像素
  • 绘制,华电国际:1363x332像素
  • 绘制-MDPI:909x222像素
  • 绘制-LDPI:682x166像素

我做了一些测试:

  1. 在我万普拉斯X图像看起来相当不错,BU在我的三星 Galaxy Nexus和Wiko Iggy的形象失去了质量。
  2. 现在,如果我从xhdpi文件夹中删除background.png,图像 在Oneplus X和Galaxy上看起来不错,但它在Wiko上仍然不好。
  3. 最后,如果我删除来自xhdpi和华电国际文件夹中的background.png中, 成像效果很不错所有手机(好吧,在万普拉斯X 的xhdpi版本是好一点,但MDPI版本仍然是也不错)。

2滚动背景的绘制代码:

backgroundArea.offsetTo(xBackground, backgroundArea.top); 
canvas.drawBitmap(background, null, backgroundArea, mPaint); 
backgroundArea.offset(backgroundArea.width(), 0); 
canvas.drawBitmap(background, null, backgroundArea, mPaint); 

为什么会这样呢?为什么它没有为正确的移动设备拍摄正确的图像,而是缩小了更大的可用图像?我如何解决这个问题? (PS:我仍在使用Eclipse ADT)。

+0

可能重复的[这](http://stackoverflow.com/questions/4837715/how-to-resize-a-bitmap-in-android),并尽量放大图像并在加载过程中按照屏幕大小调整大小。 – ADM

+0

请张贴您的画布绘图代码。 – Ircover

+0

@Ircover我编辑了文章 – Accollativo

回答

0

我的问题是Oneplus X有xxhdpi分辨率,三星Galaxy xhdpi和Wiko Iggy hdpi(You can use this app to discover the resolution)。 所以我创建了一个新的文件夹drawable-xxhdpi并移动了所有background.png“一楼楼上”(我把我的1817x443图像从xhdpi到xxhdpi等)。您可以使用此规模:

LDPI - 0.75x 
MDPI - Original size // means 1.0x here 
HDPI - 1.5x 
XHDPI - 2.0x 
XXHDPI - 3x 
XXXHDPI - 4.0x 
相关问题