Last active
November 1, 2015 07:50
-
-
Save pvllnspk/b3aa5ad5b79742478426 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private Bitmap combineBitmaps(Bitmap bmp1, Bitmap bmp2, int angle){ | |
| Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth()+2*bmp2.getWidth(), bmp1.getHeight()+2*bmp2.getHeight(), bmp1.getConfig()); | |
| Canvas canvas = new Canvas(bmOverlay); | |
| int centerX = canvas.getWidth()/2; | |
| int centerY = canvas.getHeight()/2; | |
| canvas.drawBitmap(bmp1, centerX-bmp1.getWidth()/2, centerY-bmp1.getHeight()/2, null); | |
| int R = canvas.getHeight()/2 - bmp2.getHeight()/2; | |
| int theta = angle-90; | |
| float x = (float)(centerX + R * Math.cos(theta * Math.PI / 180)); | |
| float y = (float)(centerY + R * Math.sin(theta * Math.PI / 180)); | |
| canvas.rotate(angle,x,y); | |
| canvas.drawBitmap(bmp2, x - bmp2.getWidth()/2, y - bmp2.getHeight()/2, null); | |
| return bmOverlay; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment