任何人都可以帮我解决我遇到的图形问题。这段代码根本不适用于setPolyToPoly ..它执行Camera旋转,但不执行polyToPoly转换..我不明白为什么..
final Camera camera = mCamera;
final Matrix matrix = t.getMatrix();
camera.save();
camera.translate(x, y, z);
camera.getMatrix(matrix);
camera.restore();
matrix.setPolyToPoly(sourceArr, 0, destArr, 0, sourceArr.length >> 1);
matrix.preTranslate(-0, -height);
matrix.postTranslate(0, height);
答案 0 :(得分:5)
此示例完全不符合您的问题,但可能会让您朝着正确的方向前进。在此示例中,矩阵应用于放置透视图的位图。如果我与你的片段进行比较,你会设置多面体,但它不适用于相机。
Bitmap bitmap2 = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
Canvas canvas2 = new Canvas(bitmap2);
canvas2.drawColor(Color.WHITE);
Paint rectPaint2 = new Paint();
rectPaint2.setColor(Color.GREEN);
canvas2.drawRect(20, 20, 180, 180, rectPaint2);
Matrix matrix2 = new Matrix();
float deform2 = 20f;
float[] src2 = new float[] { 0, 0, bitmap2.getWidth(), 0, bitmap2.getWidth(), bitmap2.getHeight(), 0, bitmap2.getHeight() };
float[] dst2 = new float[] { 0, 0, bitmap2.getWidth() - deform2, deform2, bitmap2.getWidth() - deform2, bitmap2.getHeight() - deform2, 0, bitmap2.getHeight() };
matrix2.setPolyToPoly(src2, 0, dst2, 0, src2.length >> 1);
Bitmap bMatrix2= Bitmap.createBitmap(bitmap2, 0, 0, bitmap2.getWidth(), bitmap2.getHeight(), matrix2, true);
ImageView ivSecond = (ImageView) findViewById(R.id.ivSecond);
ivSecond.setImageBitmap(bMatrix2);