Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void createImageInImageCenter()
- {
- Bitmap backgroundBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
- Bitmap bitmapToDrawInTheCenter = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_search);
- Bitmap resultBitmap = Bitmap.createBitmap(backgroundBitmap.getWidth(),backgroundBitmap.getHeight(), backgroundBitmap.getConfig());
- Canvas canvas = new Canvas(resultBitmap);
- canvas.drawBitmap(backgroundBitmap, new Matrix(), null);
- canvas.drawBitmap(bitmapToDrawInTheCenter, (backgroundBitmap.getWidth() - bitmapToDrawInTheCenter.getWidth()) / 2, (backgroundBitmap.getHeight() - bitmapToDrawInTheCenter.getHeight()) / 2, new Paint());
- ImageView image = (ImageView)findViewById(R.id.myImage);
- image.setImageBitmap(resultBitmap);
- }
Add Comment
Please, Sign In to add comment