How do I get the cropping frame of the address book image data?

▼魔方 西西 提交于 2019-12-20 20:18:22

问题


The AddressBook framework provides ABPersonCopyImageData for getting the contact image for each address book entry. This is great for the image data, but the user also sizes and crops the image for framing purposes. When I get the image data, I get the full image, and not the cropped image. How do I get the frame the user used to crop the image (or in lieu of that, how do I get access to the cropped image/data)?


回答1:


iOS 4.1 adds a new method: ABPersonCopyImageDataWithFormat in ABPerson.

I'm using it like this:

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

The formats allowed are:

kABPersonImageFormatThumbnail
kABPersonImageFormatOriginalSize

This allows you to get the original image or the cropped image (thumbnail).




回答2:


To some extent, it's a bug in iOS4. Previously, the address book API returned cropped data, and in iOS4 it returns the whole image data. Some people want one, some people want the other. I tend to think the whole image data is useless without the cropping frame, so hopefully that will get fixed...




回答3:


I think it's impossible to get the crop rect. The crop rect information is stored inside the sqlite database that managed by addressbook framework. But client's application cannot read another application's sqlite database, according to the sandbox structure.



来源:https://stackoverflow.com/questions/3220187/how-do-i-get-the-cropping-frame-of-the-address-book-image-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!