dra*_*fly 5 android crop matrix
每个人,
我在 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.
*/
Run Code Online (Sandbox Code Playgroud)
看完之后真的不知道怎么用。我想在 SurfaceTexture 中裁剪纹理图像并将 SurfaceTexture obj 提供给 EGLSurface 对象。
例如,原始图像是 320*720(w*h) 而我希望新图像是 320*240(w*h)
我应该怎么做才能实现这个功能?4*4 矩阵可以帮助我吗?我应该如何处理 4*4 矩阵?
它是一个兼容 GLES 的变换矩阵,可用于旋转或翻转图像。一般而言,您只需将其传递给将要渲染 SurfaceTexture 创建的 GLES 纹理的任何对象。
你可以看到它在Grafika 中使用的例子;在 ContinuousCaptureActivity.java、CameraCaptureActivity.java 和 TextureMovieEncoder.java 中搜索它。
该矩阵可用于执行各种仿射变换,例如旋转和缩放,但不能用于裁剪图像。
矩阵包含在 API 中是因为有时输入源处于“错误”方向。系统不会花费 CPU 或 GPU 周期来重新排列像素,而是随每一帧发送一个矩阵。如果帧内容按原样正确,则矩阵将是身份。如果是颠倒的,将提供一个带有适当校正的矩阵。
| 归档时间: |
|
| 查看次数: |
4005 次 |
| 最近记录: |