Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void updateTextureViewSize(int ax, int ay, int bx, int by) {
- float scaleX;
- float scaleY;
- //proportions between screen and frame dimensions
- scaleX = mVideoWidth / mDisplayWidth;
- scaleY = mVideoHeight / mDisplayHeight;
- float scaleRegionW = mVideoWidth / Math.abs(ax - bx);
- float scaleRegionH = mVideoHeight / Math.abs(ay - by);
- float scaleRegion = scaleRegionW < scaleRegionH ? scaleRegionW : scaleRegionH;
- Matrix matrix = new Matrix();
- if (scaleX > scaleY) {
- matrix.setScale(scaleRegion / scaleY, scaleRegion);
- matrix.postTranslate(-ax * (int) scaleRegion / scaleY, -ay * scaleRegion / scaleY);
- } else {
- matrix.setScale(scaleRegion, scaleRegion / scaleX);
- matrix.postTranslate(-ax * scaleRegion / scaleX, -ay * scaleRegion / scaleX);
- }
- mTextureView.setTransform(matrix);
- mTextureView.setLayoutParams(new FrameLayout.LayoutParams((int) mDisplayWidth, (int) mDisplayHeight));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement