相关疑难解决方法(0)

Android图像视图矩阵比例+翻译

我试图手动获取图像视图内部的图像并适合屏幕.我需要用矩阵来做(我稍后会动态地改变矩阵变换).

问题是我无法将图像置于视图中心(比例尺是合适的).这是代码:

// Compute the scale to choose (this works)
float scaleX = (float) displayWidth / (float) imageWidth;
float scaleY = (float) displayHeight / (float) imageHeight;
float minScale = Math.min(scaleX, scaleY);

// tx, ty should be the translation to take the image back to the screen center
float tx = Math.max(0, 
        0.5f * ((float) displayWidth - (minScale * imageWidth)));
float ty = Math.max(0, 
        0.5f * ((float) displayHeight - (minScale * imageHeight)));

// Compute the matrix
Matrix m = new Matrix(); …
Run Code Online (Sandbox Code Playgroud)

android transformation matrix imageview

30
推荐指数
2
解决办法
9万
查看次数

标签 统计

android ×1

imageview ×1

matrix ×1

transformation ×1