I want to retrieve contacts' images and display them in BitmapField
s.
So I'm collecting Bitmap objects from contacts, using this code:
Vector bitmaps = new Vector();
BlackBerryContactList contactList = (BlackBerryContactList)BlackBerryPIM.getInstance().openPIMList(BlackBerryPIM.CONTACT_LIST, BlackBerryPIM.READ_WRITE);
Enumeration contactListItems = contactList.items();
int counter = 0;
while (contactListItems.hasMoreElements()) {
BlackBerryContact contact = (BlackBerryContact)contactListItems.nextElement();
byte[] imageBytes = contact.getBinary(BlackBerryContact.PHOTO, counter);
EncodedImage encodedImage = EncodedImage.createEncodedImage(imageBytes, 0, imageBytes.length);
Bitmap bitmap = encodedImage.getBitmap();
bitmaps.addElement(bitmap);
counter++;
}
Unfortunately the code throws a java.lang.IllegalArumentException
at this method:
EncodedImage.createEncodedImage(imageBytes, 0, imageBytes.length);
How shoud I convert byte[]
image to BitmapField
?