[0]drawToTexture(1600,1600,0,0)截图出来部分图像丢失
简单的创建一个sprite,对sprite进行1600,1600的颜色绘制,对其截图就会出现图片丢失。
private nsp:Laya.Sprite;
init(): void {
this.nsp=new Laya.Sprite();
this.nsp.graphics.drawRect(0,0,1600,1600,"#ff0000");
this.nsp.mouseThrough=true;
Laya.stage.addChild(this.nsp);
this.nsp.on(Laya.Event.CLICK,this,this.drawImg,null)
//nsp.texture=Laya.stage.drawToTexture(100,100,0,0);
}
drawImg(e:Event=null):void{
var copySpr:Laya.Sprite=new Laya.Sprite();
copySpr.texture=this.nsp.drawToTexture(1600,1600,0,0) as Laya.Texture;
this.nsp.removeSelf();
copySpr.scale(.1,.1);
Laya.stage.addChild(copySpr);
}
private nsp:Laya.Sprite;
init(): void {
this.nsp=new Laya.Sprite();
this.nsp.graphics.drawRect(0,0,1600,1600,"#ff0000");
this.nsp.mouseThrough=true;
Laya.stage.addChild(this.nsp);
this.nsp.on(Laya.Event.CLICK,this,this.drawImg,null)
//nsp.texture=Laya.stage.drawToTexture(100,100,0,0);
}
drawImg(e:Event=null):void{
var copySpr:Laya.Sprite=new Laya.Sprite();
copySpr.texture=this.nsp.drawToTexture(1600,1600,0,0) as Laya.Texture;
this.nsp.removeSelf();
copySpr.scale(.1,.1);
Laya.stage.addChild(copySpr);
}
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
李文
赞同来自:
18688961270
赞同来自:
let scl = Math.min(Laya.stage.width / nsp.width, Laya.stage.height / nsp.height);
nsp.scale(scl, scl);
let iw = 1600 * scl;
let ih = 1600 * scl;
let hc: Laya.HTMLCanvas = this.img.drawToCanvas(iw, ih, nsp.x, nsp.y);
let sp = new Laya.Sprite();
sp.texture = hc.getTexture() as Laya.Texture;
Laya.stage.addChild(sp);
nsp.visible=false;