meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.56k stars 406 forks source link

Image does not draw to canvas (iOS retina devices) when pixel ratio != 1 #95

Open preich1 opened 11 years ago

preich1 commented 11 years ago

I'm rendering an image from a url into a canvas using the following:

Caman('#photoCanvas', url, function() {});

This works on all browsers PC & Mac. However, on the iPad (gen 3 & 4) and iPhone (4S), the image fails to render into the canvas and the canvas remains blank.

I suspect the issue may be related to the hiDPI / pixel ratio code.

I was able to get the image to render into the canvas on the iOS retina devices by modifying the source code to force the pixel ratio to be 1.

Are you able to replicate this as well? I'm using version 4.11 of CamanJS. Thanks!

AndryBray commented 8 years ago

Same problem on new retina iMac. Is there anyone who fixed this in some way? Thank you

gabrielseco commented 8 years ago

@AndryBray I don't know if you fixed it. I found this in the guide.

CamanJS supports HiDPI displays (also known as Retina displays) as of version 4. 
Specifying HiDPI image replacements is done via the data-caman-hidpi HTML attribute.

<img
  src="/path/to/image.jpg"
  data-caman-hidpi="/path/to/image@2x.jpg"
>