IOS图片转base64字符串和字符串转回图片

UIImage图片转成base64字符串:
    UIImage *_originImage = [UIImage imageNamed:@"full_playlist_hl.png"];

    NSData *_data = UIImageJPEGRepresentation(_image, 1.0f);

    NSString *_encodedImageStr = [_data base64Encoding];

    NSLog(@"===Encoded image:\n%@", _encodedImageStr);

Base64字符串转UIImage图片:

    NSData *_decodedImageData   = [[NSData alloc] initWithBase64Encoding:_encodedImageStr];

    UIImage *_decodedImage      = [UIImage imageWithData:_decodedImageData];

    NSLog(@"===Decoded image size: %@", NSStringFromCGSize(_decodedImage.size));
转载地址:http://www.myexception.cn/mobile/1345414.html

IOS图片转base64字符串和字符串转回图片

上一篇:el表达式讲解


下一篇:一个有关浮力的物理题