Crop cropped cut bitmap image pictures Android example

Cut, shear, clip, snip, crop a bitmap, picture, image Android example

public class ApokusActivity extends Activity {
 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}
 
	private static class SampleView extends View {
 
		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);
 
		}
 
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
 
			canvas.drawColor(Color.YELLOW);
 
 
			// you need to insert a image flower_blue into res/drawable folder
			paint.setFilterBitmap(true);
			Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
					R.drawable.flower_blue);
 
			Bitmap croppedBmp = Bitmap.createBitmap(bitmapOrg, 0, 0,
					bitmapOrg.getWidth() / 2, bitmapOrg.getHeight());
			int h = bitmapOrg.getHeight();
			canvas.drawBitmap(bitmapOrg, 10, 10, paint);
			canvas.drawBitmap(croppedBmp, 10, 10 + h + 10, paint);
 
		}
 
	}
}

crop bitmap android

This entry was posted in Android Examples Code and tagged , , . Bookmark the permalink.


Comments are closed.

29,219 views