在 canvas 中拉伸时如何调整图像大小?
How to resize an image when stretched in canvas?
我在 canvas.Below 上显示了一张图片 code.Is 当用户向各个方向拖动图片时,有什么方法可以动态拉伸或缩小图片吗?如何处理?
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(new MyView(this));
}
public class MyView extends View
{
public MyView(Context context)
{
super(context);
}
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
Bitmap _scratch = BitmapFactory.decodeResource(getResources(), R.drawable.dog);
canvas.drawColor(Color.WHITE);
canvas.drawBitmap(_scratch, 0, 0, null);
}
}
}
我在 canvas.Below 上显示了一张图片 code.Is 当用户向各个方向拖动图片时,有什么方法可以动态拉伸或缩小图片吗?如何处理?
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(new MyView(this));
}
public class MyView extends View
{
public MyView(Context context)
{
super(context);
}
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
Bitmap _scratch = BitmapFactory.decodeResource(getResources(), R.drawable.dog);
canvas.drawColor(Color.WHITE);
canvas.drawBitmap(_scratch, 0, 0, null);
}
}
}