抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台
  • JS API 列表
  • 基础
  • TTML
  • 网络
  • 媒体
  • 地图
  • 文件
  • 数据缓存
  • 地理位置
  • 设备
  • 画布
  • 界面
  • 页面导航
  • 开放接口
  • 登录
  • 用户信息
  • 广告
  • 营销能力
  • 支付
  • 分享
  • 小程序跳转
  • 抖音视频能力
  • 收货地址
  • 设置
  • 授权
  • 评价能力
  • 数据分析
  • 视频拍摄器
  • 引导关注
  • 订阅消息
  • 电商插件能力(即将废弃)
  • 流量来源识别
  • 隐私信息授权
  • web化
  • 转发和挂载
  • 侧边栏能力
  • 直播能力
  • AI/AR能力
  • AI/AR 能力简介
  • 算法管理器方案
  • 原生神经网络方案
  • 特效贴纸方案
  • 贴纸方案简介
  • tt.createStickerManager
  • StickerManager
  • StickerProcessor
  • StickerProcessor
  • StickerProcessor.paintToTexture
  • 安全能力
  • 行业开放
  • 第三方平台
  • 其它
  • 生活服务(即将废弃)
  • 基础库 2.32.0 开始支持本方法,低版本需做兼容处理,这是一个同步方法。

    将输入的图像纹理经过贴纸处理后绘制到输出图像纹理上。

    语法

    StickerProcessor.paintToTexture(inputTexture, outputTexture)

    参数说明

    inputTexture

    类型

    默认值

    必填

    说明

    最低支持版本

    WebGLTexture


    输入的图像纹理,需要是 native canvas(canvas v2) 产生的一张 WebGL Texture。

    2.32.0

    outputTexture

    类型

    默认值

    必填

    说明

    最低支持版本

    WebGLTexture


    输出的目标纹理,需要是 native canvas(canvas v2) 产生的一张 WebGL Texture,使用贴纸后的效果会被绘制在这张纹理上。

    2.32.0

    返回值

    代码示例

    开发者工具中预览

    Page({ onLoad: function () { console.log("Welcome to Mini Code"); }, onReady: function () { tt.createSelectorQuery() .select("#myCanvas") .node() .exec((res) => { this.canvas = res[0].node; this.gl = this.canvas.getContext("webgl"); this.render = require("./render"); this.render.initRenderContext(this.gl); }); }, requestEffectCamera: function () { this.effectCameraStream = tt.createEffectCameraStream(this); this.effectCameraStream.onRequest(() => { this.effectCameraStream.play(); }); this.effectCameraStream.onPlay((video) => { this.video = video; this.videoTexture = this.render.createTexture( this.gl, video.width, video.height ); this.processedTexture = this.render.createTexture( this.gl, video.width, video.height ); console.log("video size: ", video.width, video.height); this.render.renderVideoToTexture(this.gl, this.video, this.videoTexture); const paint = () => { console.log("paint"); this.render.renderVideoToTexture( this.gl, this.video, this.videoTexture ); this.processor.paintToTexture(this.videoTexture, this.processedTexture); this.render.renderToScreen(this.gl, this.processedTexture); this.canvas.requestAnimationFrame(paint); }; paint(); }); this.effectCameraStream.request(); }, requestSticker: function () { console.log("request sticker"); this.stickerManager = tt.createStickerManager("1404075"); this.stickerManager.onLoad((processor) => { console.log("sticker loaded"); this.processor = processor; }); this.stickerManager.onError((err) => { console.log("sticker load failed, ", err); }); this.stickerManager.load(); console.log("start request sticker"); }, });

    Bug & Tip

    • Tip: 参数仅支持 native canvas(canvas v2)纹理
    该文档是否有帮助?
    有帮助
    无帮助