diff --git a/src/js/controller/settings/exportimage/MiscExportController.js b/src/js/controller/settings/exportimage/MiscExportController.js index f639d51f..5c9420c6 100644 --- a/src/js/controller/settings/exportimage/MiscExportController.js +++ b/src/js/controller/settings/exportimage/MiscExportController.js @@ -12,6 +12,9 @@ ns.MiscExportController.prototype.init = function () { var cDownloadButton = document.querySelector('.c-download-button'); this.addEventListener(cDownloadButton, 'click', this.onDownloadCFileClick_); + + var selectedFrameDownloadButton = document.querySelector('.selected-frame-download-button'); + this.addEventListener(selectedFrameDownloadButton, 'click', this.onDownloadSelectedFrameClick_); }; ns.MiscExportController.prototype.onDownloadCFileClick_ = function (evt) { @@ -73,4 +76,14 @@ hexStr += ('00' + r.toString(16)).substr(-2); return hexStr; }; + + ns.MiscExportController.prototype.onDownloadSelectedFrameClick_ = function (evt) { + var frameIndex = this.piskelController.getCurrentFrameIndex(); + var fileName = this.getPiskelName_() + '-' + (frameIndex + 1) + '.png'; + var canvas = this.piskelController.renderFrameAt(frameIndex, true); + + pskl.utils.BlobUtils.canvasToBlob(canvas, function(blob) { + pskl.utils.FileUtils.downloadAsFile(blob, fileName); + }); + }; })(); diff --git a/src/templates/settings/export/misc.html b/src/templates/settings/export/misc.html index b2f6768c..054b3101 100644 --- a/src/templates/settings/export/misc.html +++ b/src/templates/settings/export/misc.html @@ -12,5 +12,14 @@ +