如何在已绘制的位图上绘制位图 canvas
How to draw bitmap over already drawn canvas
val canvas = inputSurface.lockCanvas(null)
try {
val source = Rect(200, 200, 400, 400)
canvas.drawBitmap(watermark, null, source, null)
currentFrame.draw(canvas)
} finally {
inputSurface.unlockCanvasAndPost(canvas)
}
这里我试图在从 Surface 创建的 canvas 上绘制位图(水印)。但是位图(水印)绘制在从 Surface
创建的 canvas 下面
发生这种情况是因为您首先绘制位图和框架。
通过切换绘图顺序,您应该会看到水印
val canvas = inputSurface.lockCanvas(null)
try {
//First draw the frame
currentFrame.draw(canvas)
val source = Rect(200, 200, 400, 400)
//Then draw the bitmap watermark
canvas.drawBitmap(watermark, null, source, null)
} finally {
inputSurface.unlockCanvasAndPost(canvas)
}
val canvas = inputSurface.lockCanvas(null)
try {
val source = Rect(200, 200, 400, 400)
canvas.drawBitmap(watermark, null, source, null)
currentFrame.draw(canvas)
} finally {
inputSurface.unlockCanvasAndPost(canvas)
}
这里我试图在从 Surface 创建的 canvas 上绘制位图(水印)。但是位图(水印)绘制在从 Surface
创建的 canvas 下面发生这种情况是因为您首先绘制位图和框架。 通过切换绘图顺序,您应该会看到水印
val canvas = inputSurface.lockCanvas(null)
try {
//First draw the frame
currentFrame.draw(canvas)
val source = Rect(200, 200, 400, 400)
//Then draw the bitmap watermark
canvas.drawBitmap(watermark, null, source, null)
} finally {
inputSurface.unlockCanvasAndPost(canvas)
}