1
votes

In Monotouch the only way you can get the Image from an ABPerson instance is using the Image property which returns the image in its original size.

In Objective-C there is a function called ABPersonCopyImageDataWithFormat (http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/c/func/ABPersonCopyImageDataWithFormat), which can return the thumbnailed image from the contact, but Monotouch does not provide a binding for this.

Does any body know how to call this function in Monotouch or how to create its binding?

Thanks, Danny

2

2 Answers

1
votes

Just found the solution (by disassemling the monotouch.dll and look carefully at the internal code)

[DllImport("/System/Library/Frameworks/AddressBook.framework/AddressBook")]
private static extern IntPtr ABPersonCopyImageDataWithFormat(IntPtr handle, ABPersonImageFormat format);

ABPersonImageFormat format = ABPersonImageFormat.Thumbnail;
NSData data = new NSData(ABPersonCopyImageDataWithFormat(person.Handle, format));
UIImage imgThumb = UIImage.LoadFromData(data);

Good luck with it !!!

0
votes

It's bound as MonoTouch.AddressBook.ABPerson.CopyImage (ABPersonImageFormat format);