Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
amigalo
Posts: 22
Registered: ‎03-26-2011
My Device: RIM 850

Save canvas as image to pictures on playbook

I can't find a solution for saving the contents of a canvas to an image file on the playbook.

 

Can anyone point me to a full and current solution in Javascript? I've gone through the forums and the samples. there doesn't seem to be a solution available.

 

thanks!

Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Save canvas as image to pictures on playbook

The canvas object has a toDataURL method that you use to convert canvas data into a Base64 string.

 

Others have asked the same question before, so here's a good answer from StackOverflow:

http://stackoverflow.com/questions/923885/capture-html-canvas-as-gif-jpg-png-pdf

 

var canvas = document.getElementById("mycanvas");
var imgData    = canvas.toDataURL("image/png");

var img = new Image();
img.src=imgData;
document.getElementById("foo").appendChild(img);

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
New Developer
amigalo
Posts: 22
Registered: ‎03-26-2011
My Device: RIM 850

Re: Save canvas as image to pictures on playbook

THanks.

 

I need the code that is unique to the playbook. the code that saves it to the pictures of camera or somewhere where the user can view it outside of the app.

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,543
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Save canvas as image to pictures on playbook

Here is a BlackBerry 10 sample that uses HTML5 Filesystem APIs and a canvasToBlob function to save the image:

https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/canvasToFilesystem

 

I believe it should work on the PlayBook as well.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
New Developer
amigalo
Posts: 22
Registered: ‎03-26-2011
My Device: RIM 850

Re: Save canvas as image to pictures on playbook

This doesn't work. I had already tried it and just tried it again.

I guess there is no solution for this issue.

Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: Save canvas as image to pictures on playbook

What isn't working?  Any errors, exceptions, etc? It really should run just fine on PlayBook as well, unless I'm missing something.

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.