Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Export to png image, and re-load png image back to canvas #157

Unanswered
BTGRCohen asked this question in Q&A
Discussion options

Hello,
I'm using exportImage('png') to export the drawing, and pass the data to my server via an ajax call to save the file for later viewing.
<button onClick={() => { canvasRef.current .exportImage("png") .then((data) => { saveDrawing(somedata1, somedata2, data); }) .catch((e) => { console.log(e); }); }} > Save Drawing </button>

I want to re-import the image back into the canvas, but i cant seem to find a way.
I can do this with a basic html canvas

` const canvas = document.getElementById('drawingCanvas');
const context = canvas.getContext('2d');

 drawing = new Image();
 drawing.src = "PATH_TO_IMAGE.PNG";
 drawing.onload = function() {
 context.drawImage(drawing, 0, 0);
 };`

How can i achieve this using this component?

Thanks in advance!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /