你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS圖片轉base64字符串和字符串轉回圖片

IOS圖片轉base64字符串和字符串轉回圖片

編輯:IOS開發綜合
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
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved