我想检索联系人的图像并将它们显示在BitmapField
s.
所以我正在使用以下代码从联系人中收集位图对象:
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++;
}
java.lang.IllegalArumentException
不幸的是,代码在这个方法中抛出了一个:
EncodedImage.createEncodedImage(imageBytes, 0, imageBytes.length);
我应该如何将byte[]
图像转换为BitmapField
?