ios 转图片
1 //转图片 2 - (BOOL)imageHasAlpha: (UIImage *) image 3 { 4 CGImageAlphaInfo alpha = CGImageGetAlphaInfo(image.CGImage); 5 return (alpha == kCGImageAlphaFirst || 6 alpha == kCGImageAlphaLast || 7 alpha == kCGImageAlphaPremultipliedFirst || 8 alpha == kCGImageAlphaPremultipliedLast); 9 } 10 - (NSString *) image2DataURL: (UIImage *) image 11 { 12 13 NSData *imageData = nil; 14 NSString *mimeType = nil; 15 16 if ([self imageHasAlpha: image]) { 17 imageData = UIImagePNGRepresentation(image); 18 mimeType = @"image/png"; 19 } else { 20 imageData = UIImageJPEGRepresentation(image, 1.0f); 21 mimeType = @"image/jpeg"; 22 } 23 24 25 return [imageData base64EncodedStringWithOptions: 0]; 26 27 }
我的心愿是什么呢