Bitmap combination
|
|
||||||||||||||||
Description 双色球061历史同期汇总 www.feftt.tw Translated by [email protected] Author:[email protected] Codeproject Suppose that we have two bitmaps left, right, and left is bigger than right. To create new bitmap which is combined left and right horizontally, code will as below: private void horizontalCombine() { int width = left.getWidth() + right.getWidth(); int height = Math.max(left.getHeight(), right.getHeight()); Bitmap leftRight = Bitmap.createBitmap(width, height, Config.ARGB_8888); Canvas canvas = new Canvas(leftRight); canvas.drawBitmap(left, 0, 0, new Paint()); canvas.drawBitmap(right, left.getWidth(), 0, new Paint()); imageView.setImageBitmap(leftRight); } I will explain more about code above. int width = left.getWidth() + right.getWidth(); int height = Math.max(left.getHeight(), right.getHeight()); Bitmap leftRight = Bitmap.createBitmap(width, height, Config.ARGB_8888); This will create new empty bitmap leftRight which has:
Canvas canvas = new Canvas(leftRight); ![]() canvas.drawBitmap(right, left.getWidth(), 0, new Paint()); ![]() canvas.drawBitmap(right, left.getWidth(), 0, new Paint()); And this is the result in device. ![]() With above explanation, I think you can create bitmap by combine many bitmaps vertically as below. private void verticalCombine() { int width = Math.max(left.getWidth(), right.getWidth()); int height = left.getHeight() + right.getHeight(); Bitmap leftRight = Bitmap.createBitmap(width, height, Config.ARGB_8888); Canvas canvas = new Canvas(leftRight); canvas.drawBitmap(left, 0, 0, new Paint()); canvas.drawBitmap(right, 0, left.getHeight(), new Paint()); imageView.setImageBitmap(leftRight); } |
Sponsored links
File list
Tips: You can preview the content of files by clicking file names^_^Name | Size | Date |
---|---|---|
.classpath | 475.00 B | 2013-08-14 14:07 |
.project | 857.00 B | 2013-08-16 10:42 |
AndroidManifest.xml | 894.00 B | 2013-08-14 14:07 |
BuildConfig.java | 168.00 B | 2013-08-16 10:42 |
R.java | 2.64 kB | 2013-08-16 13:42 |
ic_launcher-web.png | 50.19 kB | 2013-08-14 14:07 |
android-support-v4.jar | 543.16 kB | 2013-08-14 14:07 |
proguard-project.txt | 781.00 B | 2013-08-14 14:07 |
project.properties | 563.00 B | 2013-08-14 14:07 |
ic_launcher.png | 7.48 kB | 2013-08-14 14:07 |
left.png | 7.49 kB | 2013-08-16 11:39 |
right.png | 3.61 kB | 2013-08-16 10:49 |
ic_launcher.png | 3.69 kB | 2013-08-14 14:07 |
ic_launcher.png | 12.22 kB | 2013-08-14 14:07 |
ic_launcher.png | 24.20 kB | 2013-08-14 14:07 |
activity_main.xml | 693.00 B | 2013-08-14 14:14 |
main.xml | 409.00 B | 2013-08-16 13:41 |
dimens.xml | 203.00 B | 2013-08-14 14:07 |
dimens.xml | 277.00 B | 2013-08-14 14:07 |
styles.xml | 334.00 B | 2013-08-14 14:07 |
styles.xml | 391.00 B | 2013-08-14 14:07 |
dimens.xml | 220.00 B | 2013-08-14 14:07 |
strings.xml | 231.00 B | 2013-08-14 14:07 |
styles.xml | 697.00 B | 2013-08-14 14:07 |
MainActivity.java | 2.40 kB | 2013-08-16 13:42 |
Sponsored links
Comments
(Add your comment, get 0.1 Point)
Minimum:15 words, Maximum:160 words
- 1
- Page 1
- Total 1