端口CGAffineTransform从iOS到Android

我有下一组值:
0.439353,-0.073688,0.078788,0.439353,139.500000,72.000000
Let's name the values: a,b,c,d,tx,ty

在iOS版本的应用程序中,这些值将发送到此对象see here

在我的Android应用程序中,我正在尝试这样的事情:

Matrix mtx = new Matrix();
mtx.setValues(new float[] { a,ty,1});

this帖子,在Android中,Matrix对象接受按照该顺序(a,ty)的值,而不是iOS版本(a,ty).

我的问题是旋转和缩放正确完成,但我有翻译部分的问题.它不会在屏幕上正确定位.任何人有什么想法我做错了什么?

编辑
我正在使用矩阵在画布上发布位图,就像这样

protected void onDraw(Canvas canvas) {
    // .....
    canvas.drawBitmap(bmp,mtx,null);
}

解决方法

原因是iOS基于中心位置计算矩阵,但是android和web基于{0,0}位置.所以解决方案是您必须首先将位图移动到相对于屏幕密度的正确比例的中心位置,然后应用矩阵.我的工作良好的android代码是:
Matrix matrixA = new Matrix();
matrixA.postTranslate(-bitmapWidth/2,-bitmapHeight/2);
matrixA.postScale(screenWidth/320,screenWidth/320);
Matrix matrixB = new Matrix();
matrixB.setValues(new float[]{scale,-rotate,tX,rotate,scale,tY,0.0F,1.0F});
matrixA.postConcat(matrixB);

canvas.drawBitmap(bitmap,matrixA,null);

而网络css3代码是:

<img style="left: tX; top: tY; transform: matrix(scale,0) scale(window.screen.width/320);">

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...