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,也会失去质量。
那是为什么?