开发者

Loads an image from the given NSData of specified format(JPEG)

开发者 https://www.devze.com 2023-01-16 00:22 出处:网络
Previously I ask a question \"How to convert data to JPEG Format?\" and solution of this is: NSImage * strImage = [[NSImage alloc]initWithContentsOfFile:imagePath] ;

Previously I ask a question "How to convert data to JPEG Format?" and solution of this is:

NSImage * strImage = [[NSImage alloc]initWithContentsOfFile:imagePath] ;
NSData *imageData = [strImage TIFFRepresentation];
NSBitmapImageRep *imageRe开发者_JAVA百科p = [NSBitmapImageRep imageRepWithData:imageData];
NSNumber *compressionFactor = [NSNumber numberWithFloat:0.9];
NSDictionary *imageProps = [NSDictionary dictionaryWithObject:compressionFactor
                                         forKey:NSImageCompressionFactor];
imageData = [imageRep representationUsingType:NSJPEGFileType properties:imageProps];
NSString * str = [imageData base64Encoding];

Now I have a question, how to convert this str again into imageData.

plz help me for this too.

I want same thing to do for which QImage loadFromData() do. I am giving link for help. http://doc.qt.nokia.com/4.6/qimage.html#loadFromData-2


If the jpeg is stored in an NSData object:

NSImage* image = [[NSImage alloc] initWithData:jpegData];
0

精彩评论

暂无评论...
验证码 换一张
取 消