현재 카메라를 렌더하기 위해 textureview
인 카메라 플레이어를 만들고 있습니다. 나이가 안드로이드 기기하지만 난에이 장치에TextureView 번역 API 23의 X 및 Y 예상 동작이 없습니다.
void updateTextureMatrix(int width, int height) {
Display display = WindowManager.DefaultDisplay;
var isPortrait = (display.Rotation == SurfaceOrientation.Rotation0 || display.Rotation == SurfaceOrientation.Rotation180);
int previewWidth = orgPreviewWidth;
int previewHeight = orgPreviewHeight;
if(isPortrait) {
previewWidth = orgPreviewHeight;
previewHeight = orgPreviewWidth;
}
// determine which part to crop
float widthRatio = (float)width/previewWidth;
float heightRatio = (float)height/previewHeight;
float scaleX;
float scaleY;
if(widthRatio > heightRatio) {
// height must be cropped
scaleX = 1;
scaleY = widthRatio * ((float)previewHeight/height);
} else {
// width must be cropped
scaleX = heightRatio * ((float)previewWidth/width);
scaleY = 1;
}
Android.Graphics.Matrix matrix = new Android.Graphics.Matrix();
matrix.SetScale(scaleX, scaleY);
_textureView.SetTransform(matrix);
float scaledWidth = width * scaleX;
float scaledHeight = height * scaleY;
float dx = (width - scaledWidth) * 0.5f;
float dy = (height - scaledHeight) * 0.5f;
_textureView.TranslationX = dx;
_textureView.TranslationY = dy;
}
dx
& dy
작업의 확장 & 계산 완벽하게 정상적으로 : 미리보기 모든 사이즈에 적합있을 수 있으므로 OnSurfaceTextureUpdated
를 호출 할 때 나는 textureview을 변경하는 일부 사용자 지정 코드를 만들었습니다 API 레벨 23로 처분하면 예기치 않은 동작이 발생합니다.
을하지만 S7에 :
전화 인하에도 불구하고 제대로 위치. 이것은 내가 오래된 장치에서 어디서 렌더링되는지 알 수 없게 만듭니다. 누구든지이 사실을 확인하고 정확한 위치에서이 문제를 해결할 수 있습니까?