setPolyToPoly不适用 [英] setPolyToPoly not applied

查看:716
本文介绍了setPolyToPoly不适用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我带一个图形的问题,我有。这code不适用setPolyToPoly所有..它的摄像头旋转,而不是polyToPoly改造..我不明白为什么。

 最后的摄像头摄像头= mCamera;
最终矩阵的矩阵= t.getMatrix();

camera.save();
camera.translate(X,Y,Z);
camera.getMatrix(矩阵);
camera.restore();

matrix.setPolyToPoly(sourceArr,0,destArr,0,sourceArr.length>大于1);
矩阵preTranslate(-0,-height)。
matrix.postTranslate(0,高度);
 

解决方案

该样品并不完全适合你的问题,但可能让你在正确的方向。在此示例的矩阵施加到一个位图,它把以透视。如果我比你的代码片段,你设置polytopoly但它不应用于相机。

 位图bitmap2 = Bitmap.createBitmap(200,200,Bitmap.Config.ARGB_8888);
    帆布canvas2 =新的Canvas(bitmap2);
    canvas2.drawColor(Color.WHITE);
    油漆rectPaint2 =新的油漆();
    rectPaint2.setColor(Color.GREEN);
    canvas2.drawRect(20,20,180,180,rectPaint2);
    矩阵矩阵2 =新的Matrix();
    浮deform2 = 20F;
    浮[] SRC2 =新的浮动[] {0,0,bitmap2.getWidth(),0,bitmap2.getWidth(),bitmap2.getHeight(),0,bitmap2.getHeight()};
    浮[] DST2 =新的浮动[] {0,0,bitmap2.getWidth() -  deform2,deform2,bitmap2.getWidth() -  deform2,bitmap2.getHeight() -  deform2,0,bitmap2.getHeight()};
    matrix2.setPolyToPoly(SRC2,0,DST2,0,src2.length>大于1);
    位图bMatrix2 = Bitmap.createBitmap(bitmap2,0,0,bitmap2.getWidth(),bitmap2.getHeight(),矩阵2,真);

    ImageView的ivSecond =(ImageView的)findViewById(R.id.ivSecond);
    ivSecond.setImageBitmap(bMatrix2);
 

Can anyone help me with a graphics issue I am having. This code does not apply the setPolyToPoly at all.. it does the Camera rotation, but not the polyToPoly transformation .. I dont understand why..

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);

解决方案

This sample does not fit your question entirely but might put you in the right direction. In this sample a matrix is applied to a bitmap that puts in a perspective. If I compare to your snippet, you do set the polytopoly but it is not applied to the camera.

    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);

这篇关于setPolyToPoly不适用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆