我使用ALAsset库将照片库图像绑定到我的表视图。 因此,无论何时我将ALAsset缩略图图像作为TableView单元格图像进行绑定,图像清晰度都存在问题。它显示为低清晰度图像。 我已经从AlAsset创建了一个全分辨率的图像,并写了缩略图生成方法,我已将所得图像设置为表视图图像。 完成上述过程后,我在Table-view上获得了全分辨率图像缩略图。 但问题是性能与第一次表查看图像绑定过程(我使用缓存绑定第一次绑定图像。因此,性能将在第一次后快速)。ALAsset的低清晰度缩略图
因此,我可以知道,我如何从ALAsset中获取照片库完整清晰度缩略图图像?
我在MyTableView CellForRowIndexPath写的以下代码是
UIImageView *importMediaSaveImage=[[[UIImageView alloc] init] autorelease];
importMediaSaveImage.frame=CGRectMake(0, 0, 200,135);
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
CGImageRef iref = [myasset thumbnail];
if (iref) {
importMediaSaveImage.image = [UIImage imageWithCGImage:iref];
}
etc...
我曾尝试以下方法这是耗时
UIImageView *importMediaSaveImage=[[[UIImageView alloc] init] autorelease];
importMediaSaveImage.frame=CGRectMake(0, 0, 200,135);
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
UIImage *images;
if (iref) {
images = [UIImage imageWithCGImage:iref];
}
NSData *data = [self photolibImageThumbNailData:images];
importMediaSaveImage.image = [UIImage imageWithData:data];
etc....
photolibImageThumbNailData
-(NSData *)photolibImageThumbNailData:(UIImage *)image{
// begin an image context that will essentially "hold" our new image
UIGraphicsBeginImageContext(CGSizeMake(200.0,135.0));
// now redraw our image in a smaller rectangle.
[image drawInRect:CGRectMake(0.0, 0.0, 200.0, 135.0)];
// make a "copy" of the image from the current context
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// now grab the PNG representation of our image
NSData *thumbData = UIImagePNGRepresentation(newImage);
return thumbData;
}
谢谢。