Mercurial > hg > forks > multipaint-js
changeset 200:dffdbdb4ded6
Split mpSaveBinaryFile() into mpSaveBinaryBlob() for saving JavaScript
Blobs, which is what mpSaveBinaryFile() converts given byte array into.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 29 Aug 2018 14:06:55 +0300 |
parents | 475a6ab70cd1 |
children | 823672f83ae9 |
files | files.pde |
diffstat | 1 files changed, 14 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/files.pde Mon Aug 27 14:22:51 2018 +0300 +++ b/files.pde Wed Aug 29 14:06:55 2018 +0300 @@ -111,15 +111,8 @@ // "Save" a byte array to file. Basically creates a blob URI // and dumps it in the DOM, giving user a download. // -boolean mpSaveBinaryFile(String name, byte[] data) +boolean mpSaveBinaryBlob(String name, void blob) { - var blob = mpMakeBinaryBlob(data); - if (blob == null) - { - console.log("Could not create BLOB from data."); - return false; - } - var url = window.URL.createObjectURL(blob); if (url == null) { @@ -142,6 +135,19 @@ } +boolean mpSaveBinaryFile(String name, byte[] data) +{ + var blob = mpMakeBinaryBlob(data); + if (blob == null) + { + console.log("Could not create BLOB from data."); + return false; + } + + return mpSaveBinaryBlob(name, blob); +} + + // bordh/v = 64, 32, omag = 1 void mpSavePNGImage(String name, int fmt, boolean border, int bordh, int bordv, int omag) {