TextureView源码翻译

顶部翻译:

/**
 * <p>TextureView 可用于显示内容流。例如,这样的内容流可以是视频或 OpenGL 场景。
 * 内容流可以来自应用程序的进程以及远程进程.</p>
 *
 * <p>TextureView 只能在硬件加速窗口中使用。在软件中渲染时,TextureView 不会绘制任何内容</p>
 *
 * 和 SurfaceView 不同, TextureView 不会创建一个单独的窗口,而是像一个普通的 View
 * 这个关键区别允许 TextureView 被移动、变换、动画等。
 * 例如,您可以通过调用使 TextureView 半透明: myView.setAlpha(0.5f)
 *
 * 使用 TextureView 很简单:你需要做的就是获取它的 SurfaceTexture
 * 然后可以使用 SurfaceTexture 来渲染内容
 * 以下示例演示了如何将相机预览渲染到 TextureView 中:
 *
 * <pre>
 *  public class LiveCameraActivity extends Activity implements TextureView.SurfaceTextureListener {
 *      private Camera mCamera;
 *      private TextureView mTextureView;
 *
 *      protected void onCreate(Bundle savedInstanceState) {
 *          super.onCreate(savedInstanceState);
 *
 *          mTextureView = new TextureView(this);
 *          mTextureView.setSurfaceTextureListener(this);
 *
 *          setContentView(mTextureView);
 *      }
 *
 *      public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
 *          mCamera = Camera.open();
 *
 *          try {
 *              mCamera.setPreviewTexture(surface);
 *              mCamera.startPreview();
 *          } catch (IOException ioe) {
 *              // Something bad happened
 *          }
 *      }
 *
 *      public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
 *          // Ignored, Camera does all the work for us
 *      }
 *
 *      public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
 *          mCamera.stopPreview();
 *          mCamera.release();
 *          return true;
 *      }
 *
 *      public void onSurfaceTextureUpdated(SurfaceTexture surface) {
 *          // Invoked every time there's a new Camera preview frame
 *      }
 *  }
 * </pre>
 *
 * <p>可以通过调用 getSurfaceTexture() 或使用 TextureView.SurfaceTextureListener 来获得 TextureView 的 SurfaceTexture
 * 重要的是要知道 SurfaceTexture 只有在 TextureView 附加到窗口后才可用(并且 onAttachedToWindow() 已被调用。)
 * 因此,强烈建议您使用侦听器在 SurfaceTexture 可用时收到通知</p>
 *
 * <p>需要注意的是,只有一个生产者可以使用 TextureView。
 * 例如,如果您使用 TextureView 显示相机预览,则不能同时使用 lockCanvas() 绘制到 TextureView</p>
 *
 */

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值