mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #803 - Reuse downloadCanvas_ to download single frame canvas
This commit is contained in:
parent
594d748146
commit
8662ab65ad
@ -151,9 +151,9 @@
|
||||
};
|
||||
|
||||
// Used and overridden in casper integration tests.
|
||||
ns.PngExportController.prototype.downloadCanvas_ = function (canvas) {
|
||||
ns.PngExportController.prototype.downloadCanvas_ = function (canvas, name) {
|
||||
// Generate file name
|
||||
var name = this.piskelController.getPiskel().getDescriptor().name;
|
||||
name = name || this.piskelController.getPiskel().getDescriptor().name;
|
||||
var fileName = name + '.png';
|
||||
|
||||
// Transform to blob and start download.
|
||||
@ -223,15 +223,13 @@
|
||||
ns.PngExportController.prototype.onDownloadSelectedFrameClick_ = function (evt) {
|
||||
var frameIndex = this.piskelController.getCurrentFrameIndex();
|
||||
var name = this.piskelController.getPiskel().getDescriptor().name;
|
||||
var fileName = name + '-' + (frameIndex + 1) + '.png';
|
||||
var canvas = this.piskelController.renderFrameAt(frameIndex, true);
|
||||
var zoom = this.exportController.getExportZoom();
|
||||
if (zoom != 1) {
|
||||
canvas = pskl.utils.ImageResizer.resize(canvas, canvas.width * zoom, canvas.height * zoom, false);
|
||||
}
|
||||
|
||||
pskl.utils.BlobUtils.canvasToBlob(canvas, function(blob) {
|
||||
pskl.utils.FileUtils.downloadAsFile(blob, fileName);
|
||||
});
|
||||
var fileName = name + '-' + (frameIndex + 1) + '.png';
|
||||
this.downloadCanvas_(canvas, fileName);
|
||||
};
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user