gpt4 book ai didi

android - 使用特定坐标裁剪或缩放视频?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:05:43 29 4
gpt4 key购买 nike

有什么方法可以通过触摸从任何特定坐标缩放视频。我已经尝试了从 mediaplayer 和 surfaceview 到自定义和访问窗口管理器等所有方法。如果有人有想法,请解释一下。

最佳答案

您可以使用 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));
}

关于android - 使用特定坐标裁剪或缩放视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12216662/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com