[]相机渲染成贴图怎么保存成图片?
https://layaair.ldc.layabox.com/demo/?3d&advanced&RenderTextureDemo
这是官方相机渲染贴图的示例,怎么把RenderTexture对象保存成png或jpg图片呢?或者说怎么把它转换成二进制Blob对象吧?
let blob: Blob = new Blob([this.renderCamera.renderTarget.getData(0,0,1024,1024)]);
let url: string = URL.createObjectURL(blob);
let link: HTMLAnchorElement = document.createElement("a");
link.href = url;
link.download = "截图.png";
let ev: MouseEvent = document.createEvent("MouseEvents");
ev.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(ev);
URL.revokeObjectURL(url);
这是我写的实现,保存出来的图片无法打开!!!
这是官方相机渲染贴图的示例,怎么把RenderTexture对象保存成png或jpg图片呢?或者说怎么把它转换成二进制Blob对象吧?
let blob: Blob = new Blob([this.renderCamera.renderTarget.getData(0,0,1024,1024)]);
let url: string = URL.createObjectURL(blob);
let link: HTMLAnchorElement = document.createElement("a");
link.href = url;
link.download = "截图.png";
let ev: MouseEvent = document.createEvent("MouseEvents");
ev.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(ev);
URL.revokeObjectURL(url);
这是我写的实现,保存出来的图片无法打开!!!
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
Monica - 知识达人
赞同来自: