- 接入子域后 为什么截图失效?获得的图片信息全是空白?
在2.9.4微信基础库 不行 在2.6.0基础库的时候又可以?
2019-12-11 - canvas.toTempFilePathSync 没有Alpha通道?
绘图后截图 未画到的区域应该是透明的才对 但是现在显示的图片 透明区域是黑色的
2019-09-17 - toTempFilePath 透明区域被填充成黑色?
[图片] let canvas = document.createElement('canvas'); canvas.width = width; canvas.height = height; let ctx = canvas.getContext('2d'); let gpTexture = new cc.RenderTexture(); //绘制 //@ts-ignore gpTexture.initWithSize(width, height, cc.game._renderContext.STENCIL_INDEX8); this.gpCamera.targetTexture = gpTexture; this.gpCamera.render(this.node);//相机绘制,将屏幕上的内容更新到renderTexture中 let data = gpTexture.readPixels();//读取renderTexture中的数据 // data = this.changeAlpha(data); let rowBytes = width * 4; for (let row = 0; row < height; row++) { let srow = height - 1 - row; let imageData = ctx.createImageData(width, 1); let start = srow * width * 4; for (let i = 0; i < rowBytes; i++) { imageData.data[i] = data[start + i]; } ctx.putImageData(imageData, 0, row); } let _tempFilePath = await canvas.toTempFilePathSync( { x: 0, y: 0, width: width, height: height, destWidth: 380, destHeight: 380, fileType: 'png', quality: 1 }); wx.previewImage({ urls: [_tempFilePath] })
2019-09-16 - Canvas.toTempFilePath 截图透明背景变黑色?
[图片][图片] let canvas = document.createElement('canvas'); canvas.width = width; canvas.height = height; let ctx = canvas.getContext('2d'); let gpTexture = new cc.RenderTexture(); //绘制 //@ts-ignore gpTexture.initWithSize(width, height, cc.game._renderContext.STENCIL_INDEX8); this.gpCamera.targetTexture = gpTexture; this.gpCamera.render(this.node);//相机绘制,将屏幕上的内容更新到renderTexture中 let data = gpTexture.readPixels();//读取renderTexture中的数据 // data = this.changeAlpha(data); let rowBytes = width * 4; for (let row = 0; row < height; row++) { let srow = height - 1 - row; let imageData = ctx.createImageData(width, 1); let start = srow * width * 4; for (let i = 0; i < rowBytes; i++) { imageData.data[i] = data[start + i]; } ctx.putImageData(imageData, 0, row); } let _tempFilePath = await canvas.toTempFilePathSync( { x: 0, y: 0, width: width, height: height, destWidth: 380, destHeight: 380, fileType: 'png', quality: 1 }); wx.previewImage({ urls: [_tempFilePath] }) 明明是透明部分 怎么就变成黑色了
2019-09-12