如果我多次用画布镜像图像,为什么图像质量下降?

时间:2019-06-19 14:50:21

标签: image canvas

mirror() {
    const mirrorCanvas = document.createElement('canvas') as HTMLCanvasElement;
    const clientRect = this.parentRef.nativeElement.getBoundingClientRect();
    const image = new Image();
    image.src = this.imageBase64;
    image.onload = () => {
        mirrorCanvas.width = clientRect.width;
        mirrorCanvas.height = clientRect.height;
        const ctx = mirrorCanvas.getContext('2d');
        if (ctx) {
            ctx.scale(1, -1);
            ctx.drawImage(image, 0, 0, clientRect.width, clientRect.height);

            this.imageBase64 = (mirrorCanvas.toDataURL(`image/${this.format}`, 1));

        }
    }
}

我有这段代码,可以镜像图像。

但是,如果我继续镜像此图像,即使我将质量设置为1,也会失去质量。

那是为什么?

0 个答案:

没有答案