Update PreviewImpl.java

pull/1/head
android-dataticket 8 years ago committed by GitHub
parent e04fb369a6
commit 5ca35cdd35
  1. 42
      camerakit/src/main/base/com/flurgle/camerakit/PreviewImpl.java

@ -61,28 +61,32 @@ abstract class PreviewImpl {
return mHeight; return mHeight;
} }
void setTruePreviewSize(int width, int height) { void setTruePreviewSize(final int width, final int height) {
this.mTrueWidth = width; this.mTrueWidth = width;
this.mTrueHeight = height; this.mTrueHeight = height;
((Activity) getView().getContext()).runOnUiThread(new Runnable() {
if (width != 0 && height != 0) { @Override
AspectRatio aspectRatio = AspectRatio.of(width, height); public void run() {
int targetHeight = (int) (getView().getWidth() * aspectRatio.toFloat()); if (width != 0 && height != 0) {
float scaleY; AspectRatio aspectRatio = AspectRatio.of(width, height);
if (getView().getHeight() > 0) { int targetHeight = (int) (getView().getWidth() * aspectRatio.toFloat());
scaleY = (float) targetHeight / (float) getView().getHeight(); float scaleY;
} else { if (getView().getHeight() > 0) {
scaleY = 1; scaleY = (float) targetHeight / (float) getView().getHeight();
} } else {
scaleY = 1;
if (scaleY > 1) { }
getView().setScaleX(1);
getView().setScaleY(scaleY); if (scaleY > 1) {
} else { getView().setScaleX(1);
getView().setScaleX(1 / scaleY); getView().setScaleY(scaleY);
getView().setScaleY(1); } else {
getView().setScaleX(1 / scaleY);
getView().setScaleY(1);
}
}
} }
} });
} }
int getTrueWidth() { int getTrueWidth() {

Loading…
Cancel
Save