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
Contributor
polovi
Posts: 16
Registered: ‎03-25-2012
My Device: 9860, 9700, 9000, Blackberry Playbook
My Carrier: O2 CZ

playbook os2 canvas toDataURL image/jpeg no data

when i try to return canvas image as image/jpeg with/without image quality is returned only empty data as data:image/jpeg;base64,

 

simple example here 

http://jsfiddle.net/ptSUd/ or http://www.nihilogic.dk/labs/canvas2image/ convert to JPEG

 

image/png works fine

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

Re: playbook os2 canvas toDataURL image/jpeg no data

Can you clarify what your question is?

 

Are you seeing unexpected behavior when running your code on the PlayBook, or is this a general question about using canvas?

 

Thanks!

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.
Contributor
polovi
Posts: 16
Registered: ‎03-25-2012
My Device: 9860, 9700, 9000, Blackberry Playbook
My Carrier: O2 CZ

Re: playbook os2 canvas toDataURL image/jpeg no data

sorry my mistake, for some reason I did not send the whole query.

 

I have not a question directly, but rather I wonder if anyone can confirm this behavior in webworks application with tablet OS 2

 

thanks

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

Re: playbook os2 canvas toDataURL image/jpeg no data

Gotcha, I understand now.  I can reproduce your error with your code sample above.

 

Try changing the data type of the image to the following (jpg instead of jpeg):

 

dataUrl = canvas.toDataURL('image/jpg');

 

This seems to work.

 

I'm curious if Canvas doesn't like the image/jpeg MIME type?  When using that on PlayBook I see a runtime exception in Web Inspector for "GET data:image/jpeg;base64" (where the type is undefined).  When running the same code in Chrome, I see improved results, but it is still erroneous (black background).

 


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.
Contributor
polovi
Posts: 16
Registered: ‎03-25-2012
My Device: 9860, 9700, 9000, Blackberry Playbook
My Carrier: O2 CZ

Re: playbook os2 canvas toDataURL image/jpeg no data

When you use "image/jpg" its incorect type and returned image is png as default value same as use image/png as content type

 

https://bdsc.webapps.blackberry.com/html5/apis/canvas.html#.toDataURL

Description: The argument, if provided, controls the type of the image to be returned (e.g. PNG or JPEG). The default is image/png; that type is also used if the given type isn't supported.

 

"When using that on PlayBook I see a runtime exception in Web Inspector for "GET data:image/jpeg;base64" (where the type is undefined)."

yes this is the error

canvas.toDataURL can use content types "image/png" and "image/jpeg" with second parametr as qualiti (range 0.1 - 1.0)

http://www.w3.org/TR/html5/the-canvas-element.html#a-serialization-of-the-image-as-a-file

 

on playbook:

image/png work correct 

image/jpeg return empty data value and result is only data:image/jpeg;base64,

 

i dont know if image/jpeg before os2 work correctly, but from API reference it seams that it should work but dont work

 

-----------------

"black background"

its ok original image is transparent which jpeg dont interpretate and use black background color

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

Re: playbook os2 canvas toDataURL image/jpeg no data

Alright thanks for helping to flesh this out.

 

This sounds like a bug in the Web platform on PlayBook.  I'll file an issue in the DIT, and escalate it internally to the browser dev team.

 

https://www.blackberry.com/jira/browse/TABLET-542

 

Cheers,

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.