Note that there are some explanatory texts on larger screens.

plurals
  1. POCordova iOS - CANVAS get pixel color does not work properly (RETINA size)
    primarykey
    data
    text
    <p>In my application the user loads a photo from the library, displays it, and on a tap it gets the tapped pixel's color.</p> <p><em>I am using a variation of this snippet (first answer) <a href="https://stackoverflow.com/questions/6735470/get-pixel-color-from-canvas-on-mouseover">Get pixel color from canvas, on mouseover</a> to get the pixels color.</em></p> <p><strong>This does work if I use non-retina sizes</strong>:</p> <pre><code>var canvas = document.getElementById("myCanvas"); canvas.width = 300; canvas.height = 480; canvas.style.width = "300px"; canvas.style.height = "480px"; canvas.drawImage(img, 0, 0); </code></pre> <p>camera API:</p> <pre><code>navigator.camera.getPicture(funcSuccess, funcError, { quality: 100, targetWidth: 300, targetHeight: 480, destinationType: destinationType.FILE_URI, sourceType: source }); </code></pre> <h2>but as soon as I double the size for retina it will always returns a wrong color. (like it expects the image to be 600x960 instead of 300x480 displayed in a 600x960 canvas, ...I don't know)</h2> <pre><code>var canvas = document.getElementById("myCanvas"); canvas.width = 600; canvas.height = 960; canvas.style.width = "300px"; canvas.style.height = "480px"; canvas.drawImage(img, 0, 0); </code></pre> <p>camera API:</p> <pre><code>navigator.camera.getPicture(funcSuccess, funcError, { quality: 100, targetWidth: 600, targetHeight: 960, destinationType: destinationType.FILE_URI, sourceType: source }); </code></pre> <p>I appreciate every response. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload