fix resource saving for uploaded resources
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
parent
eea14e1cc9
commit
249e83ed07
1 changed files with 15 additions and 6 deletions
|
@ -99,11 +99,20 @@ const stampTool = () =>
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
state.resources
|
state.resources
|
||||||
.filter((resource) => !resource.temporary)
|
.filter((resource) => !resource.temporary)
|
||||||
.map((resource) => ({
|
.map((resource) => {
|
||||||
id: resource.id,
|
const canvas = document.createElement("canvas");
|
||||||
name: resource.name,
|
canvas.width = resource.image.width;
|
||||||
src: resource.image.src,
|
canvas.height = resource.image.height;
|
||||||
}))
|
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
ctx.drawImage(resource.image, 0, 0);
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: resource.id,
|
||||||
|
name: resource.name,
|
||||||
|
src: canvas.toDataURL(),
|
||||||
|
};
|
||||||
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -350,7 +359,7 @@ const stampTool = () =>
|
||||||
const image = document.createElement("img");
|
const image = document.createElement("img");
|
||||||
image.src = url.createObjectURL(file);
|
image.src = url.createObjectURL(file);
|
||||||
|
|
||||||
state.addResource(file.name, image, false);
|
image.onload = () => state.addResource(file.name, image, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue