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 Contributor
Posts: 2
Registered: ‎12-10-2013
My Device: Blackberr z10
My Carrier: Airtel

How to get Image Byte Array from PIM Contact Plugin given in Blackberry WebWorks SDK 1.0

Hi All,

 

I am using PIM Contact plugin given in Blackberry webworks Sdk.I am succesfully able to use it.

Now, i want to get byte array of photo in contact  being selected from contact picker.

Fisrt, i am launching the contact picker and using single mode, getting id of selected contact.Now on the basis of sleceted id, i am calling getContactId() method which is giving me contact object.

When i am using Contact.Photo[0].smallFilePath, it is giving me image file path of tthe selected  contact.NOw i want toget byte array of selected image.

Please, can anyone help me in getting the byte array for same.

Thanks in adavance.

Highlighted
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: How to get Image Byte Array from PIM Contact Plugin given in Blackberry WebWorks SDK 1.0

You could create a new image object programmatically from the URL:
var image = document.createElement('img');
image.src='some file path';

Once the image is loaded, you can then leverage a <canvas> to obtain the base64 encoding as described here:
http://stackoverflow.com/questions/9258932/how-to-convert-image-to-byte-array-using-javascript-only-...

Basically the path would be:
File URL > Image Object > Canvas > Base64

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.