IOS縮略圖

 UIImage *img  =  [self thumbnailWithImage:[UIImage imageWithContentsOfFile:filePath] size:CGSizeMake(120, 120)];

+ (UIImage *)thumbnailWithImage:(UIImage *)image size:(CGSize)asize


{
    
    UIImage *newimage;
    
    if (nil == image) {
        
        newimage = nil;
        
    }
    
    else{
        
        UIGraphicsBeginImageContext(asize);
        
        [image drawInRect:CGRectMake(0, 0, asize.width, asize.height)];
        
        newimage = UIGraphicsGetImageFromCurrentImageContext();
        
        UIGraphicsEndImageContext();
        
    }
    
    return newimage;
    
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章