问题
I am trying to export an image 4x the size of the canvas one.
With
var dataURL = canvas.toDataURL();
I get the image set to the size of the canvas
However when I try
var dataURL = canvas.toDataURLWithMultiplier(4);
I get the error "canvas.toDataURLWithMultiplier is not a function"
Here is my function below.
$('.preview').on('click touchstart', function() {
// save canvas image as data url (png format by default)
canvas.isGrabMode = false;
canvas.setZoom(1.0);
canvas.viewportTransform = [1, 0, 0, 1, 0, 0];
// var dataURL = canvas.toDataURL();
var dataURL = canvas.toDataURLWithMultiplier(4);
// so it can be saved as an image
document.getElementById('previewImg').src = dataURL;
canvas.renderAll();
});
回答1:
var dataURL = canvas.toDataURL({
format: 'png',
multiplier: 4
});
Use multiplier property in toDataURL().
来源:https://stackoverflow.com/questions/49647509/canvas-todataurlwithmultiplier-is-not-a-function