Skip to content

Commit

Permalink
Disable interpolation to fix blurry rendeirng on non-retina. Fixes #75
Browse files Browse the repository at this point in the history
  • Loading branch information
auchenberg committed Apr 9, 2019
1 parent f5b003e commit d4c7b0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/screencast/screencast.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.screencast {
height: 100%;
width: 100%;
image-rendering: pixelated; /* Disables interpolation. See https://stackoverflow.com/questions/7615009/disable-interpolation-when-scaling-a-canvas */
}

.img-hidden {
Expand Down
8 changes: 5 additions & 3 deletions src/components/screencast/screencast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,17 @@ class Screencast extends React.Component<any, any> {
return;
}

let devicePixelRatio = window.devicePixelRatio || 1;

const canvasWidth = this.props.width;
const canvasHeight = this.props.height;
const checkerboardPattern = this.getCheckerboardPattern(canvasElement, this.canvasContext);

canvasElement.width = window.devicePixelRatio * canvasWidth;
canvasElement.height = window.devicePixelRatio * canvasHeight;
canvasElement.width = canvasWidth * devicePixelRatio;
canvasElement.height = canvasHeight * devicePixelRatio;

this.canvasContext.save();
this.canvasContext.scale(window.devicePixelRatio, window.devicePixelRatio);
this.canvasContext.scale(devicePixelRatio, devicePixelRatio);

this.canvasContext.save();
this.canvasContext.fillStyle = checkerboardPattern;
Expand Down

0 comments on commit d4c7b0f

Please sign in to comment.