每个人,
我正在Android中使用SurfaceTexture,但我无法理解它的API:getTransformMatrix(float[] mtx),API文档如下:
/**
* Retrieve the 4x4 texture coordinate transform matrix associated with the texture image set by
* the most recent call to updateTexImage.
*
* This transform matrix maps 2D homogeneous texture coordinates of the form (s, t, 0, 1) with s
* and t in the inclusive range [0, 1] to the texture coordinate that should be used to sample
* that location from the texture. Sampling the texture outside of the range of this transform
* is undefined.
*
* The matrix is stored in column-major order so that it may be passed directly to OpenGL ES via
* the glLoadMatrixf or glUniformMatrix4fv functions.
*
* @param mtx the array into which the 4x4 matrix will be stored. The array must have exactly
* 16 elements.
*/
看完之后实在是不知道怎么用。
我想在 SurfaceTexture 中裁剪纹理图像并将 SurfaceTexture 对象提供给 EGLSurface 对象。
例如,原始图像是 320*720(w*h),我期望新图像是 320*240(w*h)
为了实现这个功能我应该怎么做呢?
4*4矩阵可以帮助我吗?
我应该用4*4矩阵做什么?
它是一个与 GLES 兼容的变换矩阵,可用于旋转或翻转图像。一般来说,您只需将其传递给要渲染 SurfaceTexture 创建的 GLES 纹理的任何内容。
您可以看到它的使用示例Grafika https://github.com/google/grafika;在 ContinuousCaptureActivity.java、CameraCaptureActivity.java 和 TextureMovieEncoder.java 中搜索它。
该矩阵可用于执行各种操作仿射变换 http://en.wikipedia.org/wiki/Affine_transformation,例如旋转和缩放,但不能用于剪辑图像。
该矩阵包含在 API 中,因为有时输入源处于“错误”方向。系统只是随每一帧发送一个矩阵,而不是花费 CPU 或 GPU 周期来重新排列像素。如果帧内容按原样正确,则矩阵将是恒等的。如果它是颠倒的,则将提供具有适当校正的矩阵。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)