【发布时间】:2014-01-27 07:46:56
【问题描述】:
我的图像不会按应有的方式缩放。据我了解,如果将图像放在 xhdpi 文件夹中,Android 会为我缩小图像,这不是性能最佳,但应该可以工作,不是吗?
这是我如何启动和绘制所有位图的示例:
public Bitmap loadBitmap(int resourceID) {
Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap tempBmp = null;
try {
tempBmp = BitmapFactory.decodeResource(getResources(), resourceID,
options);
} catch (OutOfMemoryError e) {
} catch (Error e) {
}
return tempBmp;
}
然后加载它:
bitmap = loadBitmap(R.drawable.example);
绘图:
canvas.drawBitmap(screenBitmap, screenX, screenY, null);
因为这是我正在开发的游戏,所以我在屏幕上有多个这样的游戏。
可能应该补充一点,我在模拟器中遇到了缩放问题,因为除了我自己的 Android 之外我没有任何其他 Android 可以测试,而且在我自己的手机上一切都合适,因为我就是这样测试一下。
是我遗漏了什么还是模拟器在搞乱我?
【问题讨论】: