This commit is contained in:
wxd
2024-10-03 16:17:15 +08:00
parent 44912baee3
commit 12b9dbdfbf

View File

@@ -298,41 +298,19 @@ export default defineComponent({
}
let submit = ()=>{
const newCanvas = document.createElement('canvas');
let exportCanvas = new fabric.Canvas(newCanvas, {
width: canvasImgData.width,
height:canvasImgData.height,
isDrawingMode: false, // 开启绘图模式
});
fabric.Image.fromURL(canvas.toDataURL('png'), function(img) {
img.scaleToWidth(exportCanvas.width);
img.scaleToHeight(exportCanvas.height);
img.set({
scaleX: exportCanvas.width / img.width,
scaleY: exportCanvas.height / img.height
});
exportCanvas.setBackgroundImage(img, exportCanvas.renderAll.bind(exportCanvas));
let data = exportCanvas.toDataURL({
format: "png", // 导出格式为 PNG
quality: 1, // 图片质量为 1最高质量
});
},{ crossOrigin: "Anonymous" });
// newCanvas.width = canvasImgData.width;
// newCanvas.height = canvasImgData.height;
// const newCtx = newCanvas.getContext('2d');
// newCtx.drawImage(
// canvas,
// 0, 0,
// canvas.width,
// canvas.height,
// 0, 0,
// newCanvas.width,
// newCanvas.height
// );
// console.log(exportCanvas.toDataURL('jpg'));
emit('submitLiquefaction',canvas.toDataURL('image/png'))
newCanvas.width = canvasImgData.width;
newCanvas.height = canvasImgData.height;
const newCtx = newCanvas.getContext('2d');
newCtx.drawImage(
canvas,
0, 0,
canvas.width,
canvas.height,
0, 0,
newCanvas.width,
newCanvas.height
);
emit('submitLiquefaction',newCanvas.toDataURL('image/png'))
cancelDsign()
}
return {