|
|
@ -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() { |
|
|
|