Note that there are some explanatory texts on larger screens.

plurals
  1. POBlackberry webworks 10 using image from picture taken\uploaded
    primarykey
    data
    text
    <p>I am stuck with an issue and I have no idea what to try next.</p> <p>In My application I offer my user a choice to either take a photo or choose a photo from the gallery. This part works fine, the problem arises with the saving\reading of the photo. Lets take this from the camera invoke perspective.</p> <pre><code>function startCameraApp() { PhotoTaken = false; blackberry.event.addEventListener("onChildCardClosed", sharePhoto); blackberry.invoke.invoke({ target: "sys.camera.card" }, onInvokeSuccess, onInvokeError); } </code></pre> <p>and in sharePhoto I have the following code...</p> <pre><code>function sharePhoto(request) { var image = new Image(); image.src = "file://" + request.data; image.onload = function () { // Now here I need to read the image file and convert it into base64. var resized = resizeMe(image); // the resizeMe function is given below and it simply makes my image smaller var imagedata = resized.split("base64,"); sessionStorage.setItem("MyNewPicture", imagedata); } } function resizeMe(img) { var canvas = document.createElement('canvas'); var max_width = 600; var max_height = 600; var width = img.width; var height = img.height; // calculate the width and height, constraining the proportions if (width &gt; height) { if (width &gt; max_width) { height = Math.round(height * max_width / width); width = max_width; } } else { if (height &gt; max_height) { width = Math.round(width * max_height / height); height = max_height; } } //resize the canvas and draw the image data into it img.width = width; img.height = height; canvas.width = width; canvas.height = height; canvas.classname += "ui-hidden"; var ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0, width, height); return canvas.toDataURL(); } </code></pre> <p>So the app runs and it takes the photo and everything seems fine, yet the data uploaded to local storage is simply a blank screen. It works 100% in the blackberry 10 simulator, but not on my device. On the device it saves an empty string. </p> <p><strong>Edit</strong></p> <p>Ok. So I added this to my function for testing purposes and I am still stuck and I don't know what to do...</p> <pre><code>function sharePhoto(request) { var image = new Image(); image.src = "file://" + request.data; image.onload = function () { // Now here I need to read the image file and convert it into base64. var resized = resizeMe(image); // the resizeMe function is given below and it simply makes my image smaller var imagedata = resized.split("base64,"); alert(imagedata); // This returns a blank popup sessionStorage.setItem("MyNewPicture", imagedata); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload