当我想使用以下功能绘制图像时,我的图像总是比它的源图像大3倍。因此,如果我想要显示1000x1000的大小,我必须将源图像大小调整为335x335,然后它将不会被切割。
screen = new Screen(BitmapFactory.decodeResource(getResources(), R.drawable.rose1), 40, 200, 1000, 1000, 1);
Screen.java中的屏幕构造:
public Screen (Bitmap res, int xPos, int yPos, int w, int h, int numFrames){
super.x = xPos;
super.y = yPos;
height = h;
width = w;
Bitmap [] image = new Bitmap[numFrames];
spritesheet = res;
for (int i = 0; i<image.length; i++){
image[i] = Bitmap.createBitmap(spritesheet, i*width, 0, width, height);
//image[i] = Bitmap.createScaledBitmap(spritesheet, width, height, true);
}
animation.setFrames(image);
animation.setDelay(10);
}
但是当我使用
时 image[i] = Bitmap.createScaledBitmap(spritesheet, width, height, true);
一切都很好,但如果我想添加动画对象怎么办?
答案 0 :(得分:0)
最后我找到了解决方案。 应该将inScaled设置为false。
BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = false;
screen = new Screen(BitmapFactory.decodeResource(getResources(), R.drawable.rain2, options), 40*WIDTH_X/1080, 200*HEIGHT_Y/1920, 1000,1000, 1);