CamanJS icon indicating copy to clipboard operation
CamanJS copied to clipboard

camanJS not working in android

Open ShreenivasCh opened this issue 11 years ago • 4 comments

CamanJs effects are not working on android mobile... why????????

ShreenivasCh avatar Sep 05 '13 09:09 ShreenivasCh

how are you trying to use the effects on the android mobile phone?

myjangle avatar Sep 21 '13 12:09 myjangle

if I use existing canvas of an image like this: Caman(clone[0], function () { //clone is jquery of the canvas in the DOM this.render(); }); it will show a blank image on android emulator but it will works good on desktop browser (Chrome). I did a little bit of debug to Caman and I found in the function "Caman.prototype.hiDPIAdjustments" the ratio is 1 in chrome and 2 in android, this is because "window.devicePixelRatio" return 2 in android instead of 1. therefore, it makes the canvas to show a blank image.

hope It will help you.

Additional things: after removing this piece of code for caman: if (ratio !== 1) { Log.debug("HiDPI ratio = " + ratio); this.scaled = true; this.originalWidth = this.canvas.width; this.originalHeight = this.canvas.height; this.canvas.width = this.originalWidth * ratio; this.canvas.height = this.originalHeight * ratio; this.canvas.style.width = "" + this.originalWidth + "px"; this.canvas.style.height = "" + this.originalHeight + "px"; this.context.scale(ratio, ratio); this.width = this.canvas.width; return this.height = this.canvas.height; }

This is the code that makes the problem and it will get into the if statement if ratio is not 1 (the same value to talk about above). if I remove this piece of code it works good, but it not the way to solve the problem and I can not fix the bug because I don't really understand way this statement here from the first place.

ghost avatar Sep 26 '13 18:09 ghost

good point noampz! i solved my android problems by adding simply "data-caman-hidpi-disabled" to my canvas like stated in http://camanjs.com/guides/#BasicUsage. works like a charm now ;)

das-akeem avatar May 12 '14 21:05 das-akeem

I have this same problem on both Android and iPhones, and I'd rather not disable hidpi display if the device supports it (which I believe iPhones are supposed to). Is there a solution for the iPhone that will allow me to still use HiDPI/Retina?

kaheidt avatar Aug 19 '14 14:08 kaheidt