设为首页 加入收藏

TOP

Android中Bitmap位图的渲染与操作
2014-11-24 14:00:03 来源: 作者: 【 】 浏览:0
Tags:Android Bitmap 位图 渲染 操作

1.通过一张资源文件得到一个位图


Bitmap bmp = BitmapFactory.decodeResource(this.getResources(),R.drawable.icon);


2.绘制位图


canvas.drawBitmap(bmp,0,0,paint);


3.旋转位图


方法一:


canvas.save();


canvas.rotate(30,bmp.getWidth()/2,bmp.getHeight()/2);


canvas.drawBitmap(bmp,0,0,paint);


canvas.restore();


方法二:


Matrix mx = new Matrix();


mx.postRotate(30,bmp.getWidth()/2,bmp.getHeight()/2);


canvas.drawBitmap(bmp,0,0,paint);


4平移位图


方法一:


canvas.save();


canvas.translate(10,10);


canvas.drawBitmap(bmp,0,0,paint);


canvas.restore();


方法二:


Matrix mx = new Matrix();


mx.postTranslate(10,10);


canvas.drawBitmap(bmp,0,0,paint);


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇使用Python脚本处理OC中的中文字.. 下一篇Android 利用缓存机制实现文件下载

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: