Reputation: 569
i've a class which extends view ...in which i have two bitmap images to show one over another ....for this im am trying to convert one bitmap image to a drawable image but it dsnt show over the first one what i'm trying this is.....
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);
but when i'm using this it dsnt shows image...
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();
}
}
Upvotes: 0
Views: 1049
Reputation: 401
Drawable d =new BitmapDrawable(bitmap);
use this to convert bitmap image to drawable.
Upvotes: 3