1
每一個的圖像比例。 我是Android開發人員。 我想用矩陣從圖像的顯示部分的中心縮放圖像。 因此,我用矩陣縮放了我的圖像。然後用計算的指針移動它。 但是,應用程序無法正常工作。 這找不到正確的中心,所以當它移動時,它向右移動。 這是爲什麼? 我找不到問題。從顯示中心使用矩陣
代碼如下。
matrix.reset();
curScale += 0.02f;
orgImage.getHeight();
w = orgImage.getWidth();
matrix.postScale(curScale, curScale);
rtnBitmap = Bitmap.createBitmap(orgImage, 0, 0, w, h, matrix, true);
curImageView.setImageBitmap(rtnBitmap);
Matrix curZoomOutMatrix = new Matrix();
pointerx =(int) ((mDisplayWidth/2 - curPosX) * curScale);
curPosX = - pointerx;
pointery =(int) ((mDisplayWidth/2 - curPosY) * curScale);
curPosY = - pointery;
Log.i("ZoomOut-> posX = ", Integer.toString(curPosX));
Log.i("ZoomOut-> posY = ", Integer.toString(curPosY));
curZoomOutMatrix.postTranslate(curPosX, curPosY);
curImageView.setImageMatrix(curZoomOutMatrix);
curImageView.invalidate();
你有中心zoomIn和縮小(ZoomOut)任何示例代碼與矩陣的ImageView的? 誰能爲此解釋? 請幫幫我。