UPNG-如何处理透明图像?

时间:2019-06-26 23:32:17

标签: transparency apng

使用UPNG,我得到的是黑色而不是透明的颜色。我该如何正确处理?

不知道从哪里开始

saveAPNG() {
    const arrAnimationSpeed = new Array(this.arrayBufferData().length);
    arrAnimationSpeed.fill(this.canvasState.frameRate);
    const imageData = UPNG.encode(this.arrayBufferData(), this.canvasState.width, this.canvasState.height, 0, arrAnimationSpeed);
   download(imageData, 'newAPNG.apng', 'apng');
   return imageData;

}

 arrayBufferData() {
   const data = [];
   const canvas2All = document.querySelectorAll('.frame-canvas');

   canvas2All.forEach((canvas2: HTMLCanvasElement) => {
     const ctx: CanvasRenderingContext2D = canvas2.getContext('2d');
     const partData = ctx.getImageData(0, 0, canvas2.width, canvas2.height).data.buffer;
     data.push(partData);
   });
   return data;
 }

我实际上可以使我的aPNG透明吗?

0 个答案:

没有答案