首页 > 解决方案 > Android图形在不同的api上绘制错误的视角

问题描述

制作应用程序时,我需要绘制一个透视图。在 api> 27 上一切都很好,但在 27 及以下奇怪的事情!底部两点错误的构建视角

    float[] srcT = {
            0, 0, // Coordinate of top left point
            0, height, // Coordinate of bottom left point
            wight, height, // Coordinate of bottom right point
            wight, 0  // Coordinate of top right point
    };

    float[] dstT = {
            top_left_x, top_left_y, // Coordinate of top left point
            bottom_left_x, bottom_left_y, // Coordinate of bottom left point
            bottom_right_x, bottom_right_y, // Coordinate of bottom right point
            top_right_x, top_right_y  // Coordinate of top right point
    };

    Shader shader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
    matrix.setPolyToPoly(srcT, 0, dstT, 0, 4);
    shader.setLocalMatrix(matrix);
    paint.setShader(shader);

它在 28 api 上:

图像1

这是 22 api:

图2

标签: androidgraphicsperspective

解决方案


推荐阅读