UIImage 與 base64字符串 互轉:

UIImage圖片轉成base64字符串:php

   

UIImage *_originImage = [UIImage imageNamed:@"full_playlist_hl.png"];    NSData *_data = UIImageJPEGRepresentation(_image, 1.0f);    NSString *_encodedImageStr = [_data base64Encoding];    NSLog(@"===Encoded image:\n%@", _encodedImageStr);html

 

    Base64字符串轉UIImage圖片:app

NSData *_decodedImageData   = [[NSData alloc] initWithBase64Encoding:_encodedImageStr];    UIImage *_decodedImage      = [UIImage imageWithData:_decodedImageData];    NSLog(@"===Decoded image size: %@", NSStringFromCGSize(_decodedImage.size));ui

相關文章
相關標籤/搜索