【问题标题】:understanding Android drawBitmap() method了解Android drawBitmap() 方法
【发布时间】:2023-04-02 04:15:01
【问题描述】:

请有人解释一下调用 canvas.drawBitmap(,,,) 时究竟发生了什么。当调用 onDraw(Canvas canvas) 方法时,提供了一个具有底层位图的画布。我的困惑是,当我们调用canvas.drawBitmap(otherBitmap,,,) ,前一个位图会发生什么我的意思是原始位图,它是画布的底层位图。

【问题讨论】:

    标签: android canvas bitmap android-custom-view


    【解决方案1】:

    为了回答您的问题,drawBitmap() 在您指定的位置重绘指定位图。如果画布上当前存在某些东西,则将其涂上。

    drawBitmap()有不同的实现:

    drawBitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha, Paint paint)
    
    drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint)
    
    drawBitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)
    
    drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)
    
    drawBitmap(Bitmap bitmap, float left, float top, Paint paint)
    
    drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)
    

    这应该会有所启发:drawBitmap()

    Android Canvas Documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-06
      • 2014-07-20
      相关资源
      最近更新 更多