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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Visitor
Posts: 1
Registered: ‎06-26-2013
My Device: Q10
My Carrier: 61488789894

HTML5 Camera access - Q10 problem

[ Edited ]
Hey guys,
 
I am using the file input control, and JS to capture an image from the gallery/camera in the Dev alpha Q10, and Z10... the problem is it is not working on the Q10 as an "app" - but is working as a webapp (through the browser)
 
On click of the input, photo gallery pops up (on the Q10 and the Z10).
 
The problem is when I select a photo, it calls the method below (with the file input parameter).
 
On the Z10 it works 100%. Same as when I test it as a "webapp" on Android & iPhone.
 And returns the jpeg (base64) encoded image... (i use a canvas to convert it from png).
 
But on the Q10 when in an app - it just does nothing... No errors or anything. 
As mentioned, when it's through the webapp (browser) it works on the Q10
Note, this is the dev alpha version - not sure if that matters.
 
 
Anyways, on the off chance a code snippet it's helpful...
 
       function get_image_uri(file_input, callback) {
		if(file_input.files && file_input.files[0]){

			var file_reader = new FileReader();
			file_reader.onload = $.proxy(function(e) {

				//conversion canvas to convert from png to jpeg.
				var canvas = document.createElement("canvas");
				var ctx = canvas.getContext('2d');
				var img = new Image();

				img.src=file_reader.result;
				img.onload = $.proxy(function() {
					canvas.width = img.width;
					canvas.height = img.height;
					ctx.drawImage(img, 0, 0);
					var uri = canvas.toDataURL("image/jpeg");

					callback(uri);

				}, this);

			}, this);

			var url = file_reader.readAsDataURL(file_input.files[0]);
		}
	}

 

 

Thanks!

 

 

Chris.

Retired
Posts: 71
Registered: ‎09-19-2012
My Device: No sleep til BlackBerry 10
My Carrier: Bell

Re: HTML5 Camera access - Q10 problem

Have you tried dropping the FileReader part?  It could be a bug with that.  I wasn't able to reproduce on my end so it could just be dev alpha c thing.  However, using FileReader is unnecessary.  Try to just do the following:

 

img.src=window.URL.createObjectURL(file_input.files[0]);

 

and that way you can skip the FileReader load event.

 

Hope that yields some results!

 

Cheers,

Graham

------------------------------
@grahamzibar
-_- zZZ