- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I toDataURL function supported on a canvas for a crosswalk deployment ?
Do I need plugin ?
this code:
var ctx = document.getElementById('avatarCanvas').getContext('2d'); ar img = new Image(); img.src = url; img.onload = function () { ctx.drawImage(img,0,0); alert( ctx.toDataURL('image/png') );
fails with "undefined" function
- Tags:
- HTML5
- Intel® XDK
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
toDataURL is supported on crosswalk. toDataURL works on the canvas element, I think in your code you are applying toDataURL on the context.
Try doing this :
var canvas = document.getElementById('avatarCanvas'); alert( canvas.toDataURL('image/png') );
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As Swati points out, toDataUrl is a property of a canvas element, not a canvas context. I think you should have code like this:
You may also have to deal with cross origin problems (e.g. "img.crossOrigin = true;") but this seemed to work for me.
-
var el = document.getElementById('avatarCanvas'); var ctx = el.getContext('2d'); var img = new Image(); img.src = url; img.onload = function () { ctx.drawImage(img,0,0); alert( el.toDataURL('image/png') ); }
You may also have to deal with cross origin problems (e.g. "img.crossOrigin = true;") but this seemed to work for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK Thank you all for your help !
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page