private void setupMatrix(int width, int height, int degree) {
Matrix matrix = new Matrix();
RectF src = new RectF(0, 0, width, height);
RectF dst = new RectF(0, 0, width, height);
RectF screen = new RectF(dst);
matrix.postRotate(degree, screen.centerX(), screen.centerY());
matrix.mapRect(dst);
matrix.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER);
matrix.mapRect(src);
matrix.setRectToRect(screen, src, Matrix.ScaleToFit.CENTER);
matrix.postRotate(degree, screen.centerX(), screen.centerY());
mVideoPlayerView.setTransform(matrix);
}
这个旋转视频的方法,数学原理没看懂阿
OpenGLES滤镜开发汇总 —— 仿抖音九屏特效分屏特效中的九屏特效。纹理横向和纵向缩成三分之一再填充,不需要做裁剪处理。shader如下: 效果如下: