2012-08-31 2 views

답변

3

SurfaceView을 사용하면됩니다. 내 기사 Surface View - Video Cropping을 확인하십시오.

자르기 용 코드 SurfaceView.

private void updateTextureViewSize(int viewWidth, int viewHeight) { 
    float scaleX = 1.0f; 
    float scaleY = 1.0f; 

    if (mVideoWidth > viewWidth && mVideoHeight > viewHeight) { 
     scaleX = mVideoWidth/viewWidth; 
     scaleY = mVideoHeight/viewHeight; 
    } else if (mVideoWidth < viewWidth && mVideoHeight < viewHeight) { 
     scaleY = viewWidth/mVideoWidth; 
     scaleX = viewHeight/mVideoHeight; 
    } else if (viewWidth > mVideoWidth) { 
     scaleY = (viewWidth/mVideoWidth)/(viewHeight/mVideoHeight); 
    } else if (viewHeight > mVideoHeight) { 
     scaleX = (viewHeight/mVideoHeight)/(viewWidth/mVideoWidth); 
    } 

    // Calculate pivot points, in our case crop from center 
    int pivotPointX = viewWidth/2; 
    int pivotPointY = viewHeight/2; 

    Matrix matrix = new Matrix(); 
    matrix.setScale(scaleX, scaleY, pivotPointX, pivotPointY); 

    mTextureView.setTransform(matrix); 
    mTextureView.setLayoutParams(new FrameLayout.LayoutParams(viewWidth, viewHeight)); 
} 
+2

실례합니다. 귀하의 기사는 TextureView를 사용하여 시연합니다. SurfaceView를 사용하는 것과 같은 결과입니까? – Yeung

+1

SurfaceView로 자르기를 할 수 있다고 생각하지 않습니다. –

관련 문제