Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. private void updateTextureViewSize(int ax, int ay, int bx, int by) {
  2. float scaleX;
  3. float scaleY;
  4.  
  5. //proportions between screen and frame dimensions
  6. scaleX = mVideoWidth / mDisplayWidth;
  7. scaleY = mVideoHeight / mDisplayHeight;
  8.  
  9. float scaleRegionW = mVideoWidth / Math.abs(ax - bx);
  10. float scaleRegionH = mVideoHeight / Math.abs(ay - by);
  11. float scaleRegion = scaleRegionW < scaleRegionH ? scaleRegionW : scaleRegionH;
  12.  
  13. Matrix matrix = new Matrix();
  14. if (scaleX > scaleY) {
  15. matrix.setScale(scaleRegion / scaleY, scaleRegion);
  16. matrix.postTranslate(-ax * (int) scaleRegion / scaleY, -ay * scaleRegion / scaleY);
  17. } else {
  18. matrix.setScale(scaleRegion, scaleRegion / scaleX);
  19. matrix.postTranslate(-ax * scaleRegion / scaleX, -ay * scaleRegion / scaleX);
  20. }
  21. mTextureView.setTransform(matrix);
  22. mTextureView.setLayoutParams(new FrameLayout.LayoutParams((int) mDisplayWidth, (int) mDisplayHeight));
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement