1

I'm able to get original image of person from address book but I would like to ask, if there is any way how to get cropped image (in case, user has taken a picture and zoomed just some part of it). I found a way, how to do this in objective-c:

NSData *imageData = [(NSData *)ABPersonCopyImageDataWithFormat(
          recordRef, kABPersonImageFormatThumbnail) autorelease];

I can't find a way how to get this thumbnail in MonoTouch. I found just this enumeration which has definitely something to do with that, but nothing else :(

http://docs.go-mono.com/MonoTouch.AddressBook.ABPersonImageFormat/Members

Please, has anybody any idea? Thanks in advance

Ryan
  • 26,884
  • 9
  • 56
  • 83
elschima
  • 11
  • 1

2 Answers2

0

Try MonoTouch.AddressBook.ABPerson.Image propery. And MonoTouch.AddressBook.ABPerson.HasImage property to shure that MonoTouch.AddressBook.ABPerson has a picture.

jamapag
  • 9,290
  • 4
  • 34
  • 28
  • This ..ABPerson.Image property holds photo of the person - this really works, my problem is that this image is original image as someone took it by camera. But usually people are zooming (and cropping) this image before save and I'm interested in this version of image - this thumbnail image. – elschima Jun 27 '11 at 06:11
0

When you right-click on the Image property of an ABPerson instance and then select 'Go to declaration', you will find the code Monotouch implements for this property:

public NSData Image {
get {
    return (NSData)Runtime.GetNSObject(ABPerson.ABPersonCopyImageData(this.Handle));
}
set {
    if (!ABPerson.ABPersonSetImageData(this.Handle, (value ? value.Handle : IntPtr.Zero), &IntPtr ))
    {
            throw CFException.FromCFError();
    }
}

}

You see that a ABPerson.ABPersonCopyImageData method is used to return the Image, so there is a method to get the image, but I think it is marked Internal.

So I think we need to Bind the Objective C functions ourself. Is there anybody out there who knows how to do this or has any experience with this?

dennieku
  • 83
  • 9