mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-22 20:25:49 +00:00
Add quality parameter for toDataURL and toDataURLWithMultiplier
This commit is contained in:
parent
8e429ceaf9
commit
34be62682f
1 changed files with 6 additions and 4 deletions
|
|
@ -553,11 +553,12 @@
|
|||
* Exports canvas element to a dataurl image.
|
||||
* @method toDataURL
|
||||
* @param {String} format the format of the output image. Either "jpeg" or "png".
|
||||
* @param {Number} quality quality level (0..1)
|
||||
* @return {String}
|
||||
*/
|
||||
toDataURL: function (format) {
|
||||
toDataURL: function (format, quality) {
|
||||
this.renderAll(true);
|
||||
var data = (this.upperCanvasEl || this.lowerCanvasEl).toDataURL('image/' + format);
|
||||
var data = (this.upperCanvasEl || this.lowerCanvasEl).toDataURL('image/' + format, quality);
|
||||
this.renderAll();
|
||||
return data;
|
||||
},
|
||||
|
|
@ -567,9 +568,10 @@
|
|||
* @method toDataURLWithMultiplier
|
||||
* @param {String} format (png|jpeg)
|
||||
* @param {Number} multiplier
|
||||
* @param {Number} quality (0..1)
|
||||
* @return {String}
|
||||
*/
|
||||
toDataURLWithMultiplier: function (format, multiplier) {
|
||||
toDataURLWithMultiplier: function (format, multiplier, quality) {
|
||||
|
||||
var origWidth = this.getWidth(),
|
||||
origHeight = this.getHeight(),
|
||||
|
|
@ -596,7 +598,7 @@
|
|||
|
||||
this.renderAll(true);
|
||||
|
||||
var dataURL = this.toDataURL(format);
|
||||
var dataURL = this.toDataURL(format, quality);
|
||||
|
||||
this.contextTop.scale(1 / multiplier, 1 / multiplier);
|
||||
this.setWidth(origWidth).setHeight(origHeight);
|
||||
|
|
|
|||
Loading…
Reference in a new issue