Is it possible to map a bitmap into a trapezoid

时间:2015-05-12 23:28:27

标签: android drawing

I have a bitmap. I would like to draw this bitmap into a trapezoid, anchoring the four corners of the original bitmap to the corners of the trapezoid. Is this possible in Android?

1 个答案:

答案 0 :(得分:1)

您可以使用Matrix.setSkew

matrix.setSkew(0.5f, 0.5f, bitmap.getWidth/2, bitmap.getHeight/2);
canvas.drawBitmap(bitmap, matrix, null);

Canvas.drawBitmapMesh

canvas.drawBitmapMesh(bitmap, 1, 1, new float[]{
    0.3f, 0,
    0.6f, 0,
    0, 1, 
    1, 1,
}, 0, null, 0, null);

您需要尝试使用float []和skew的值。