English 中文(简体)
iphone使用ALAsset使用URL检索图像
原标题:iphone retrieve image using URL using ALAsset

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

问题回答

你拿到ALAsset了吗?一旦你做到了,获得图像就很容易了。要获取缩略图,资源有一个方法。。。缩略图。

UIImage*img=[UUIImage imageWithCGImage:[myAsset缩略图]]

要获得完整的Res图像,必须通过默认表示。

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

希望这能有所帮助

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

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


来自fullScreenImage的文档:

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

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

查看此方法

+ (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





相关问题
Using QCView and iSight to capture image

I have a QCView that loads a Quartz file which gives you iSights feedback (basically like a QTCaptureView) Everything displays fine The button simply takes a snapshot using the following simple ...

Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Transform rectangular image into trapezoid

In .NET how can I transform an image into a trapezoid. The Matrix class supports rotation, shear, etc, but I can t see a trapezoidal transformation. I m using the usual System.Drawing.* API, but I m ...

Rotate image through Y-axis on web page

What are my options for rotating an image on a web page through the Y-axis? I m not sure if I even have the terminology right. Is this called a rotate or a transform. Most of the searches that I ve ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

Convert from 32-BPP to 8-BPP Indexed (C#)

I need to take a full color JPG Image and remap it s colors to a Indexed palette. The palette will consist of specific colors populated from a database. I need to map each color of the image to it s "...