在 MonoTouch 中获取人物的裁剪照片(在 iPhone 上)

发布于 2024-11-17 03:11:40 字数 525 浏览 3 评论 0原文

我可以从地址簿中获取人的原始图像,但我想问,是否有任何方法可以获取裁剪图像(以防用户拍摄了照片并仅缩放了其中的一部分)。我找到了一种方法,如何在 Objective-C 中执行此操作:

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

我找不到在 MonoTouch 中获取此缩略图的方法。我发现这个枚举肯定与此有关,但没有其他:(

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

请问,有人有什么想法吗? 提前致谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神魇的王 2024-11-24 03:11:40

尝试 MonoTouch.AddressBook.ABPerson.Image 属性。以及 MonoTouch.AddressBook.ABPerson.HasImage 属性,以确保 MonoTouch.AddressBook.ABPerson 具有图片。

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

可遇━不可求 2024-11-24 03:11:40

当您右键单击 ABPerson 实例的 Image 属性,然后选择“转到声明”时,您将找到 Monotouch 为此属性实现的代码:

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();
    }
}

}

您会看到 ABPerson.ABPersonCopyImageData 方法用于返回 Image,因此有一种获取图像的方法,但我认为它被标记为“内部”。

所以我认为我们需要自己绑定 Objective C 函数。有没有人知道如何做到这一点或有这方面的经验?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文