Skip to content

Commit

Permalink
Wait for the image load event in PNG output
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow committed Dec 28, 2022
1 parent ab3e965 commit f1a92c2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/LegendRenderer/PngOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export default class PngOutput extends AbstractOutput {
const yPx = cssDimensionToPx(y);
this.expandHeight(yPx + imgHeight);
const image = new Image();
const imageLoaded = new Promise(resolve => image.onload = resolve);
image.src = dataUrl;
await imageLoaded;
this.context.drawImage(image, xPx, yPx, imgWidth, imgHeight);
if (drawRect) {
this.context.strokeStyle = '1px solid black';
Expand Down

0 comments on commit f1a92c2

Please sign in to comment.