0

我有一个扩展视图的类...在其中我有两个位图图像以显示一个在另一个上....为此我正在尝试将一个位图图像转换为可绘制的图像但它在第一个图像上显示了什么我正在尝试这是.....

public class ShowCanvas extends View {

Bitmap CanvasBitmap;
Bitmap ScaledBitmap;
Bitmap smallbitmap;
private static final int INVALID_POINTER_ID = -1;

private Drawable mImage;
private float mPosX;
private float mPosY;

private float mLastTouchX;
private float mLastTouchY;
private int mActivePointerId = INVALID_POINTER_ID;

private ScaleGestureDetector mScaleDetector;
private float mScaleFactor = 1.f;



public ShowCanvas(Context context) {
    super(context);
    // TODO Auto-generated constructor stub

    ScaledBitmap = DrawView.scaled;



**when i get the image from drawable it shows over the first one...**   

mImage = getResources().getDrawable(R.drawable.dress01);

但是当我使用它时,它会显示图像...

mImage = new BitmapDrawable(getResources(), Dress.bitmap);

    System.out.println("Drawable" + mImage);



    int X = mImage.getMinimumWidth();

    int Y = mImage.getIntrinsicHeight();

    System.out.println(" Rough" + X + "\t" + Y);


    mImage.setBounds(0, 0, mImage.getIntrinsicWidth(),
            mImage.getIntrinsicHeight());

}

public void setBitmap(Bitmap bitmap) {
    // TODO Auto-generated method stub
    CanvasBitmap = bitmap;

    System.out.println("CanvasBitmap" + CanvasBitmap);

    int X = CanvasBitmap.getHeight();
    int Y = CanvasBitmap.getWidth();

    System.out.println("CanvasBitmap " + X + "\t" + Y);

}



@Override
protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    Paint mpaint = new Paint();
    canvas.save();

    canvas.drawBitmap(ScaledBitmap, 0, 0, mpaint);

    mImage.draw(canvas);

    Log.i("Debug", "mImage.draw(canvas)");

    canvas.restore();

}

}

4

1 回答 1

3
Drawable d =new BitmapDrawable(bitmap); 

使用它来将位图图像转换为可绘制的。

于 2012-05-14T04:45:45.127 回答