Questions tagged [devicepixelratio]
33 questions
6
votes
0 answers
Why is my device resolution / devicePixelRatio not equal to my CSS' viewport width?
My device (Macbook Pro 2019 16") has a resolution of 3072 x 1920. When entering the realm of CSS, pixel units are "normalized". From my understanding, each CSS pixel is equal to my window.devicePixelRatio in device pixels. In my case,…

Tom
- 8,536
- 31
- 133
- 232
2
votes
0 answers
Canvas gets blurred on various coordinates (browser zoom level < 100%)
I am using a device that has devicePixelRatio of 1. On scroll, I am re-rendering the canvas by adding 1 or -1 to the y position. It affects the rendering quality and more importantly, the rendering position keeps changing on scroll. For instance, if…

UNKNOWN .MR.
- 21
- 2
2
votes
0 answers
Why doesn't window.devicePixelRatio change on zoom in Safari?
Context: I'm using window.devicePixelRatio to determine the display resolution for a few canvases on a website.
To the best of my knowledge, the DPR value should change when zooming in and out on a website. This is what happens on Chrome. But it…

Stanley Zhong
- 21
- 3
2
votes
3 answers
Resolution aware images not working - Flutter
I am trying to add resolution aware image markers to google maps by converting each image to bitmap as such:
static Future makeBitmapDescriptor(String path) {
return BitmapDescriptor.fromAssetImage(
…

Shaveen
- 175
- 2
- 12
2
votes
1 answer
HTML5 canvas is showing as aliased on downscaling a drawing in Chrome
Requirement:
So I am using a html5 canvas to perform drawings on an iPad(2732 * 2048) and store the pixels drawn so I can reuse them.
Now I need to show the same drawing on a website as a downscaled version (615 * 460) by redrawing it per…

abhijitsinha89
- 58
- 1
- 10
2
votes
1 answer
can't get sharp lines on html canvas element
I have been having quite a time trying to get pixel perfect straight lines on a canvas element. I have tried a number of solutions that have been proposed on other stackoverflow issues and on an issue opened on the WebGL github repo. I'm still not…

JohnRDOrazio
- 1,358
- 2
- 15
- 28
2
votes
0 answers
Reliably calculate accurate device resolution
Assuming window.devicePixelRatio and device-width are set by display manufacturers and could potentially return incorrect values, are there any other reliable ways to accurately calculate the resolution of the physical pixels on a display?
I'll use…

David J. Aldred
- 21
- 1
- 3
2
votes
0 answers
Incorrect window.devicePixelRatio in iframe
Basically window.devicePixelRatio shows the wrong value when used within an iframe. It shows 2.5 on top level but 2 within an iframe.
You can see the value used within an iframe here:
https://codepen.io/KennyLindahl/pen/wvBxjGb
Now type…

Kenny Lindahl
- 161
- 7
2
votes
0 answers
How to set correct sizes from Adobe Illustrator / Sketch to flutter?
I've created a design using Sketch and AI (adobe illustrator) and basing on that I've created the structure on flutter.
The problem there is that the pixels and pt sizes on Sketch do not corresponding to the size of pixels (?) in Flutter.
I know…

hooverest
- 31
- 2
2
votes
0 answers
Images look blurred when I used canvasPattern as pointBackgroundColor
Expected Behavior
Images should look good without blur in all screen resolutions. It looks good in the PC resolution.
Current Behavior
Images looks blurred on mobile resolutions.
Here is my code
HTML