zoukankan      html  css  js  c++  java
  • LayaBox 摄像机Unit8Array数据获取、截图

    LayaBox 本身可以直接利用数据渲染

     1 {
     2     let renderTextureWidth = 512;
     3     let renderTextureHeight = 512;
     4     let camera = this.scene.addChild(new Laya.Camera(0, 0.01, 500));
     5     camera.renderTarget = new Laya.RenderTexture(renderTextureWidth, renderTextureHeight);
     6     camera.renderingOrder = 0;
     7     camera.clearFlag = Laya.BaseCamera.CLEARFLAG_SOLIDCOLOR;
     8     this.scene3DImage = new Laya.Image();
     9     this.scene3DImage.source = new Laya.Texture(camera.renderTarget);
    10     Laya.stage.addChild(this.scene3DImage);
    11 }
    View Code

    但是如果需要获取相机数据的话,则调用它自带的函数getData()即可,如下

    {
        let renderTextureWidth = 512;
        let renderTextureHeight = 512;
        let camera = this.scene.addChild(new Laya.Camera(0, 0.01, 500));
        camera.renderTarget = new Laya.RenderTexture(renderTextureWidth, renderTextureHeight);
        camera.renderingOrder = 0;
        camera.clearFlag = Laya.BaseCamera.CLEARFLAG_SOLIDCOLOR;
        this.scene3DImage = new Laya.Image();
        this.scene3DImage.source = new Laya.Texture(camera.renderTarget);
        Laya.stage.addChild(this.scene3DImage);
    
        let pixels = new Uint8Array(renderTextureWidth * renderTextureHeight * 4);
        this.camera.renderTarget.getData(0, 0, renderTextureWidth, renderTextureHeight, pixels);
        console.log(pixels);
    }
  • 相关阅读:
    C#心得与经验(二)
    C#心得与经验(一)
    与C#的第一次~
    2014应届生面试经验详谈。
    Block基本用法
    OC中得那些“点”
    PCH文件的使用
    UIScrollView的subViews使用小注意
    分享一下本人录制图像处理与OpenCV学习视频
    OpenCV 3.2正式发布啦
  • 原文地址:https://www.cnblogs.com/huojiaoqingchun0123/p/15419906.html
Copyright © 2011-2022 走看看