Zoom Camera2 Preview usando TextureView
Tengo un problema con mi Zoom de vista previa para la API de Camera2. Estoy usando un TextureView.
Quiero hacer zoom solo en la vista previa Stream que se mostró en TextureView.
Quiero hacer zoom en el área donde uso el gesto de zoom.
Yo uso el SimpleOnScaleGestureListener!
Agregué el siguiente código. El zoomingFactor y la posición x e y son correctos.
private void updateTextureViewSize(float xPosi,float yPosi, float scale){
float scaleX = 1.0f;
float scaleY = 1.0f;
float mVideoWidth = mCamcontrol.getmPreviewSize().getWidth();
float mVideoHeight = mCamcontrol.getmPreviewSize().getHeight();
int rotation = getWindowManager().getDefaultDisplay().getRotation();
RectF viewRect = new RectF(0, 0, 1440, 2560);
RectF bufferRect = new RectF(0, 0, mVideoHeight, mVideoWidth);
bufferRect.offset(xPosi - bufferRect.centerX(), yPosi - bufferRect.centerY());
//16:9 faktor
scaleX = ((mScale * scale) / 9f) * 16f;
scaleY = ((mScale * scale) / 16f) * 9f;
Matrix matrix = new Matrix();
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL);
scalefactorView.setText(String.valueOf(xPosi) + " " + String.valueOf(yPosi));
matrix.setScale(scaleY, scaleX, xPosi, yPosi);
matrix.postRotate(90 * (rotation - 2), xPosi, yPosi);
mTextureView.setTransform(matrix);
}
El zoom es correcto, pero no la posición donde hago zoom. ¡Por ejemplo! Cuando hago zoom en la posición derecha / centro, solo veo el rectángulo izquierdo / superior de Stream.
Agregué elsiguientes fotos para entender el problema.