iphone 使用 ALAsset 使用 URL 检索图像

发布于 2024-10-18 00:40:36 字数 221 浏览 4 评论 0原文

我想知道如何使用 URL 检索图像。我正在使用 ALAsset。我从以下链接中找到了答案(带有勾号的答案)显示从 iPhone 中的 ALAsset 检索到的 URL 中的图像。如何检索图像并上传?

I want to know how to how to retrieve a image using URL. I am using the ALAsset. I followed the answer (the one with the tick mark) from the following link display image from URL retrieved from ALAsset in iPhone. How to retrieve the image and upload it?

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

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

发布评论

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

评论(3

或十年 2024-10-25 00:40:36

您成功获得 ALAsset 了吗?一旦完成,获取图像就很容易了。要获取缩略图,资产有一个方法...thumbnail。

UIImage *img = [UIImage imageWithCGImage:[myAssetthumbnail]];

要获取完整的 Res 图像,您必须使用默认表示形式。

UIImage *img = [UIImage imageWithCGImage:[[myAsset defaultRepresentation] fullResolutionImage]

希望这有帮助

Have you managed to get the ALAsset? Once you do, getting the image is easy. To get a thumbnail, the asset has a method...thumbnail.

UIImage *img = [UIImage imageWithCGImage:[myAsset thumbnail]];

To get the full Res image you have to go through the default representation.

UIImage *img = [UIImage imageWithCGImage:[[myAsset defaultRepresentation] fullResolutionImage]

Hope this helps

贪恋 2024-10-25 00:40:36

我知道这是一个老问题,但为了防止其他人出现,我找到了另一种方法(需要 iOS 5+),该方法返回更容易处理的图像:

UIImage *img = [UIImage imageWithCGImage:[[myAsset defaultRepresentation] 
               fullScreenImage];

来自 fullScreenImage 的文档:< br>

在 iOS 5 及更高版本中,此方法返回完全裁剪、旋转和调整的图像 - 与用户在照片或图像选择器中看到的完全一样。

Monkybonk05 的答案确实有效,但它没有被裁剪或旋转。

I know this is an old question but just in case anyone else comes I found another method (requires iOS 5+) that returns an easier to work with image:

UIImage *img = [UIImage imageWithCGImage:[[myAsset defaultRepresentation] 
               fullScreenImage];

From the docs of fullScreenImage:

In iOS 5 and later, this method returns a fully cropped, rotated, and adjusted image—exactly as a user would see in Photos or in the image picker.

monkybonk05's answer does work, but it not cropped or rotated.

梦巷 2024-10-25 00:40:36

看看这个方法,

+ (UIImage *)imageFromAsset:(ALAsset *)asset
{
    ALAssetRepresentation *representation = [asset defaultRepresentation];
    return [UIImage imageWithCGImage:representation.fullResolutionImage
                               scale:[representation scale]
                         orientation:(UIImageOrientation)[representation orientation]];
}

我根据这个要点稍微调整了它: https://gist.github.com/ NR4TR/8576048

Check out this method

+ (UIImage *)imageFromAsset:(ALAsset *)asset
{
    ALAssetRepresentation *representation = [asset defaultRepresentation];
    return [UIImage imageWithCGImage:representation.fullResolutionImage
                               scale:[representation scale]
                         orientation:(UIImageOrientation)[representation orientation]];
}

I've slightly adjusted it based on this gist: https://gist.github.com/NR4TR/8576048

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