InputStream inputStream = getResources().openRawResource(R.drawable.test);
BitmapDrawable drawable = new BitmapDrawable(inputStream);
Bitmap bitmap = drawable.getBitmap();
bitmap = ThumbnailUtils.extractThumbnail(bitmap, 40, 40);
<pre name="code" class="java">imageView.setImageBitmap(bitmap);
BitmapDrawable bitmapDrawable = (BitmapDrawable) image1.getDrawable();
Bitmapbitmap = bitmapDrawable.getBitmap();
image2.setImageBitmap(Bitmap.createBitmap(bitmap, x, y, 120, 120));