如何在移动时缩放位图



在触摸上我创建并移动位图。现在,我想在移动时扩展位图。我该如何带来这种效果?即时通讯使用Sprite对象将其移动。我想创造出射击的幻想。我想这将是通过逻辑来实现的。

public class SpriteObject {
    private Bitmap bitmap;
    private int x;      
    private int y;  
    private int x_move = 0;
    private int y_move = -1;

    public SpriteObject(Bitmap bitmap, int x, int y) {
        this.bitmap = bitmap;
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }
    public int getY() {
        return y;
    }
    public Bitmap getBitmap() {
        return bitmap;
    }

    public void setMoveX(int movex){
        x_move = movex;
    }
    public void setMoveY(int movey){
        y_move = movey;
    }
    public void setX(int x) {
        this.x = x;
    }
    public void setY(int y) {
        this.y = y;
    }
    public void setBitmap(Bitmap bitmap) {
        this.bitmap = bitmap;
    }
    public void draw(Canvas canvas) {
        canvas.drawBitmap(bitmap, x - (bitmap.getWidth() / 2), y - (bitmap.getHeight() / 2), null);
    }
    public void update(int adj_mov) {
            x += (adj_mov * x_move);
            y += (adj_mov * y_move);
    }
    public void still(int adj_still) {
        x += (adj_still * x_move);
        y += (adj_still * y_move);
    }

}

请尝试:

int h = 100; // height in pixels
int w = 100; // width in pixels
Bitmap photoBitmap = Bitmap.createScaledBitmap(yourSelectedImageBitmap, h, w,true);