我需要帮助将旋转视图中的选定点转换回原始图像中的对应点。因此,例如,如果我在旋转视图中单击左上角 ( 0,0 ),它应该对应于原始图像中的 (0,1280)。
无论旋转如何,解决方案都可以加分。
Original Image ( 1920 x 1280 ) Rotated View ( for display on phone )
+----------------------------+ +-----------------+
|(0,0) | |(0,0) | ( 1280 x 1920 )
| | | |
| | | x |
| x | | ( click ) |
| ( what is this point ) | | |
| | | |
| | | |
+----------------------------+ | |
(1920,1280) | |
| |
| |
| |
| |
| |
| |
| |
+-----------------+
(1280,1920)
更新
/*
This is how I build the matrix used to perform the initial rotation from the original to the rotated image. This matrix also includes scaling
Code base: Android/Java
bitmap ( bitmap i'm scaling/rotating )
canvas ( the canvas being drawn to )
Note: bitmap is in landscape mode / canvas is in portrait
*/
Matrix matrix = new Matrix();
float centerX = canvas.getWidth() >> 1;
float centerY = canvas.getHeight() >> 1;
rAngle = 90;
scaleH = ((float) canvas.getHeight()) / bitmap.getWidth();
scaleW = ((float) canvas.getWidth()) / bitmap.getHeight();
scaler.preScale(scaleH, scaleW);
scaler.postRotate(rAngle, centerY, centerX);
float nx = (canvas.getHeight() - canvas.getWidth()) / 2;
scaler.postTranslate(-nx, nx);
canvas.drawBitmap(bitmap,scaler,null);
我几乎不是一个数学家,所以任何牵手都会受到赞赏。:)