位图组合
|
分享有礼! 》
|
|||||||||||||
代码介绍翻译 maninwest@Codeforge 作者:huyletran@ Codeproject 假设有两个位图(左) left, (右)right, 左位图比右位图大。要创建一个左右位图横向结合的新位图,代码将如下所示: 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); } 上述代码的详细介绍. int width = left.getWidth() + right.getWidth(); int height = Math.max(left.getHeight(), right.getHeight()); Bitmap leftRight = Bitmap.createBitmap(width, height, Config.ARGB_8888); 这将创建新的空位图 leftRight ,该位图有:
Canvas canvas = new Canvas(leftRight); ![]() canvas.drawBitmap(right, left.getWidth(), 0, new Paint()); ![]() canvas.drawBitmap(right, left.getWidth(), 0, new Paint()); 这是设备中的结果。 ![]() 纵向结合位图的代码 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
源码文件列表
温馨提示: 点击源码文件名可预览文件内容哦 ^_^名称 | 大小 | 修改日期 |
---|---|---|
.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 |
资源评论
(提交有效评论获得积分)
评论内容不能少于15个字,不要超出160个字。
- 1
- 第1页
- 共1页