protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView myImageView = (ImageView)findViewById(R.id.imageview); Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.image1); Bitmap resizedbitmap = Bitmap.createBitmap(bmp , 0, 0,bmp.getWidth()/2 , bmp.getHeight()); myImageView.setImageBitmap(resizedbitmap); ImageView myImageView2 = (ImageView)findViewById(R.id.imageview2); myImageView2.setImageResource(R.drawable.image1); }利用 BitmapFactory.decodeResource 取得 Bitmp之後
再使用 Bitmap.createBitmap 給定 start_x , start_y ,width, height
取得希望得到的Bitmap範圍
沒有留言:
張貼留言