Add low res images to map
This commit is contained in:
parent
91789996e8
commit
1e5245668c
|
@ -74,19 +74,28 @@ window.loadFileAsync = function(fullPath, bitmap, callback) {
|
||||||
generationCanvas.width = sm[0];
|
generationCanvas.width = sm[0];
|
||||||
generationCanvas.height = sm[1];
|
generationCanvas.height = sm[1];
|
||||||
|
|
||||||
// Create dummy from data uri
|
// Draw
|
||||||
FS.createPreloadedFile(path, filename, generationCanvas.toDataURL(), true, true, function() {
|
var img = new Image;
|
||||||
// Return control to C++
|
img.onload = function(){
|
||||||
callback(); callback = () => {};
|
const ctx = generationCanvas.getContext('2d');
|
||||||
|
ctx.drawImage(img, 0, 0, sm[0], sm[1]);
|
||||||
|
|
||||||
// Lazy load and refresh
|
// Create dummy from data uri
|
||||||
load(() => {
|
FS.createPreloadedFile(path, filename, generationCanvas.toDataURL(), true, true, function() {
|
||||||
const reloadBitmap = Module.cwrap('reloadBitmap', 'number', ['number'])
|
// Return control to C++
|
||||||
reloadBitmap(bitmap);
|
callback(); callback = () => {};
|
||||||
|
|
||||||
|
// Lazy load and refresh
|
||||||
|
load(() => {
|
||||||
|
const reloadBitmap = Module.cwrap('reloadBitmap', 'number', ['number'])
|
||||||
|
reloadBitmap(bitmap);
|
||||||
|
});
|
||||||
|
}, console.error, false, false, () => {
|
||||||
|
try { FS.unlink(path + "/" + filename); } catch (err) {}
|
||||||
});
|
});
|
||||||
}, console.error, false, false, () => {
|
};
|
||||||
try { FS.unlink(path + "/" + filename); } catch (err) {}
|
|
||||||
});
|
img.src = sm[2];
|
||||||
} else {
|
} else {
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
console.warn('No sizemap for image', mappingKey);
|
console.warn('No sizemap for image', mappingKey);
|
||||||
|
|
|
@ -22,7 +22,13 @@ if [ -f $file ]
|
||||||
then
|
then
|
||||||
sz=`identify -format "%w,%h" "${file}" 2>/dev/null`
|
sz=`identify -format "%w,%h" "${file}" 2>/dev/null`
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "\"$fl\": [${sz}]," >> bitmap-map.js
|
convert "$file" -resize 64x64\> "conv.png"
|
||||||
|
mimetype=$(file -bN --mime-type "conv.png")
|
||||||
|
content=$(base64 -w0 < "conv.png")
|
||||||
|
duri="data:$mimetype;base64,$content"
|
||||||
|
rm "conv.png"
|
||||||
|
|
||||||
|
echo "\"$fl\": [${sz},\"${duri}\"]," >> bitmap-map.js
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue