drawBitmap的基本用法

1、对图片剪接和限定显示区域
  drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint);
  官方解释如下

Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. If the source rectangle is not null, it specifies the subset of the bitmap to draw.

大概意思是:如果src不为null的话,按src截取subBitmap,并将subBitmap通过自动缩放/平移去适应目标矩形(dst);如果src为null的画,subBitmap就是原bitmap

参数解释:
Rect src: 对图片进行裁截(src.left,src.top默认为0,0),若是空null则显示整个图片
RectF dst:是 裁剪后的图片在Canvas画布中显示的区域(裁剪区会被自动缩放/平移以适应它)

参考:
[官网Canvas drawBitmap](https://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint))
drawBitmap基本用法

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容