首页 > 其他 > 详细

图片处理

时间:2015-05-08 12:29:06      阅读:177      评论:0      收藏:0      [点我收藏+]
 (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize
{
    // Create a graphics image context
    UIGraphicsBeginImageContext(newSize);
    
    // Tell the old image to draw in this new context, with the desired
    // new size
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    
    // Get the new image from the context
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    
    // End the context
    UIGraphicsEndImageContext();
    
    // Return the new image.
    return newImage;
}
-(NSString *)ImageBase64String:(NSString *)path image:(UIImage *)oimage{
    
    UIImage *_originImage = nil;
    if (path) {
        _originImage = [UIImage imageWithContentsOfFile:path];
    }else{
        _originImage = oimage;
    }
    
    NSData *_data = UIImageJPEGRepresentation(_originImage, 1.0f);
    //    NSString *_encodedImageStr = iOS_Agin7?[_data base64Encoding]:[_data base64EncodedDataWithOptions:0];
    
    NSString *_encodedImageStr = nil;
    
    if ([_data respondsToSelector:@selector(base64EncodedDataWithOptions:)])
    {
        // It exists, so let‘s call it
        _encodedImageStr = [_data base64EncodedStringWithOptions:0];
    }
    else
    {
        // Use the old API
        _encodedImageStr = [_data base64Encoding];
    }
    
    //    NSLog(@"===Encoded image:\n%@", _encodedImageStr);
    return _encodedImageStr;
}

 

图片处理

原文:http://www.cnblogs.com/keyan1102/p/4487037.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!