在 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);
        }
     }
}

就我而言,这也适用于拉伸

http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

或者你也可以这样试试

http://developer.sonymobile.com/2011/06/27/how-to-scale-images-for-your-android-application/