开发者

Help on saving the images

开发者 https://www.devze.com 2023-01-31 18:27 出处:网络
I have the follwoing code to save the image but it seems poor in quality... is there any way to get the images in a fine quality?

I have the follwoing code to save the image but it seems poor in quality...

is there any way to get the images in a fine quality?

Thanks for any help

UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width,
                                                   self.view.bounds.size.height-50)); 
CGContextRef context = UIGraphicsGetCurrentContext();
CGCo开发者_如何学JAVAntextTranslateCTM(context, 0, -50);    
[self.view.layer renderInContext:context];
UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(  );
NSData* imageData = [NSData dataWithData:UIImageJPEGRepresentation( viewImage,0 )];


First thing that comes to mind is a compression quality parameter in UIImageJPEGRepresentation function - you set it to the lowest quality (0.0), try to set it to maximum quality value:

NSData* imageData = [NSData dataWithData:UIImageJPEGRepresentation( viewImage,1.0 )];


One option as it is mentioned in Vladimir's answer. Another option is you can use the UIImagePNGRepresentation. It will use the PNG format.

0

精彩评论

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