美文网首页
drawBitmap的基本用法

drawBitmap的基本用法

作者: dawen92 | 来源:发表于2016-11-03 13:23 被阅读0次

    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基本用法

    相关文章

      网友评论

          本文标题:drawBitmap的基本用法

          本文链接:https://www.haomeiwen.com/subject/mjgbuttx.html