Şu anda kameranın işlenmesi için textureview
numaralı fotoğraf makinesini kullanıyorum. eski android cihazlar ama ben sahip cihazlardaTextureView Translation API üzerinde beklenen beklenmeyen davranış 23 23
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
işin ölçekleme & hesaplama mükemmel iyi: Önizleme Her boyuta olabileceğinden OnSurfaceTextureUpdated
çağrıldığında ben textureview değiştirmek için bazı özel kod oluşturduk API düzey 23 ile elimden geldiğimde beklenmedik davranışlar atılır.
Ama S7:
galaksi S3 doğru görüntüler görüntünün bir sürü kapalı
telefon kesintileri, rağmen doğru şekilde konumlandırılması. Bu bana alt kısımların eski cihazlarda nerede oluşturulmadığına inanmamı sağlıyor. Bunu onaylayan ve bu sorunu düzeltmek için doğru konumda bana işaret eden var mı?