Skip to content

Commit

Permalink
improve image export quality
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Dec 5, 2023
1 parent d6cc179 commit b6c464f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion teammapper-frontend/mmp/src/map/handlers/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ export default class Export {

image.onload = () => {
const canvas = document.createElement('canvas'),
context = canvas.getContext('2d')
context = canvas.getContext('2d'),
pixelRatio = window.devicePixelRatio || 1

canvas.width = image.width
canvas.height = image.height

canvas.style.width = canvas.width +'px'
canvas.style.height = canvas.height +'px'
canvas.width *= pixelRatio
canvas.height *= pixelRatio
context.setTransform(pixelRatio,0,0,pixelRatio,0,0)

context.drawImage(image, 0, 0)
context.globalCompositeOperation = 'destination-over'
context.fillStyle = '#ffffff'
Expand Down

0 comments on commit b6c464f

Please sign in to comment.