1.图片转base64串及反转回图片
UIImage图片转成base64字符串:
1 UIImage *_originImage = [UIImage imageNamed:@"full_playlist_hl.png"]; 2 NSData *_data = UIImageJPEGRepresentation(_image, 1.0f);3 NSString *_encodedImageStr = [_data base64Encoding]; 4 NSLog(@"===Encoded image:\n%@", _encodedImageStr);
Base64字符串转UIImage图片:
1 NSData *_decodedImageData = [[NSData alloc] initWithBase64Encoding:_encodedImageStr]; 2 UIImage *_decodedImage = [UIImage imageWithData:_decodedImageData]; 3 NSLog(@"===Decoded image size: %@", NSStringFromCGSize(_decodedImage.size));
时间: 2024-11-08 20:15:21