这是我的代码我想缩放我的可绘制图像并设置图像视图请帮助我 在我的代码中,我想缩放 bitmap1 ,请检查我的代码
protected Bitmap murge()
{
Murge_Bitmap = null;
Murge_Bitmap = Bitmap.createBitmap(600, 600, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(Murge_Bitmap);
Resources res = getResources();
bitmap1 = BitmapFactory.decodeResource(res, R.drawable.sample_pic);
Bitmap bitmap2=Bitmap.createScaledBitmap(bitmap1, 600, 600, true);
Drawable drawable1 = new BitmapDrawable(Bitmap_recieve);
Drawable drawable2 = new BitmapDrawable(bitmap2);
// c.drawBitmap(Murge_Bitmap, 500,500, null);
drawable1.setBounds(200, 200, 400, 400);
drawable2.setBounds(200, 240, 400, 400);
drawable1.draw(c);
drawable2.draw(c);
return Murge_Bitmap;
}
答案 0 :(得分:0)
你可以用这个: 解码资源并使用scalingfactor
将其传递给此函数public static Bitmap ScaleBitmap(Bitmap bm, float scalingFactor) {
int scaleHeight = (int) (bm.getHeight() * scalingFactor);
int scaleWidth = (int) (bm.getWidth() * scalingFactor);
return Bitmap.createScaledBitmap(bm, scaleWidth, scaleHeight, true);
}
缩放因子的