Use device instead of data pixel ratio to determine canvas size

This commit is contained in:
Andreas Hocevar
2022-07-10 17:33:36 +02:00
parent 6086459cba
commit f3a05ba82d
3 changed files with 8 additions and 11 deletions

View File

@@ -175,10 +175,8 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
const resolution = viewState.resolution; const resolution = viewState.resolution;
const rotation = viewState.rotation; const rotation = viewState.rotation;
// desired dimensions of the canvas in pixels // desired dimensions of the canvas in pixels
const width = Math.round((getWidth(extent) / resolution) * imagePixelRatio); const width = Math.round((getWidth(extent) / resolution) * pixelRatio);
const height = Math.round( const height = Math.round((getHeight(extent) / resolution) * pixelRatio);
(getHeight(extent) / resolution) * imagePixelRatio
);
// set forward and inverse pixel transforms // set forward and inverse pixel transforms
composeTransform( composeTransform(

View File

@@ -268,10 +268,8 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
const resolution = frameState.viewState.resolution; const resolution = frameState.viewState.resolution;
const tilePixelRatio = tileSource.getTilePixelRatio(pixelRatio); const tilePixelRatio = tileSource.getTilePixelRatio(pixelRatio);
// desired dimensions of the canvas in pixels // desired dimensions of the canvas in pixels
const width = Math.round((getWidth(extent) / resolution) * tilePixelRatio); const width = Math.round((getWidth(extent) / resolution) * pixelRatio);
const height = Math.round( const height = Math.round((getHeight(extent) / resolution) * pixelRatio);
(getHeight(extent) / resolution) * tilePixelRatio
);
const layerExtent = const layerExtent =
layerState.extent && fromUserExtent(layerState.extent, projection); layerState.extent && fromUserExtent(layerState.extent, projection);
@@ -369,15 +367,16 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
} }
} }
const canvasScale = tileResolution / viewResolution; const canvasScale =
((tileResolution / viewResolution) * pixelRatio) / tilePixelRatio;
// set forward and inverse pixel transforms // set forward and inverse pixel transforms
composeTransform( composeTransform(
this.pixelTransform, this.pixelTransform,
frameState.size[0] / 2, frameState.size[0] / 2,
frameState.size[1] / 2, frameState.size[1] / 2,
1 / tilePixelRatio, 1 / pixelRatio,
1 / tilePixelRatio, 1 / pixelRatio,
rotation, rotation,
-width / 2, -width / 2,
-height / 2 -height / 2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 109 KiB