ALAsset ライブラリを使用して、フォト ライブラリの画像をテーブル ビューにバインドしています。したがって、ALAsset Thumbnail イメージを TableView セル イメージとしてバインドするときはいつでも、イメージの明瞭度に問題があります。明瞭度の低いイメージとして表示されます。AlAsset からフル解像度の画像を作成し、サムネイル生成方法を記述しました。結果の画像をテーブルビュー画像として設定しました。上記のプロセスを実行した後、Table-view でフル解像度の画像サムネイルを取得しました。しかし、問題は、最初のテーブル ビュー イメージ バインド プロセスのパフォーマンスでした (最初のバインド後にキャッシュを使用してイメージをバインドしました。そのため、初回以降はパフォーマンスが高速になります)。
ALAsset から Photo-library の完全な透明度のサムネイル画像を取得するにはどうすればよいですか?
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;
}
ありがとう。