mercredi 8 avril 2015

IOS save image in document folder with set dimanation (width and height )

get image from uimageview and save in app document folder its done but the problem is when image is so big resolution then how to set fixed width and height image here is my code please help me



NSInteger N=100000000;
NSUInteger r = arc4random_uniform(N) + 1;
NSString *myimageName=[NSString stringWithFormat:@"image%lu.png",(unsigned long)r];

NSData *pngData = UIImagePNGRepresentation(self.myImage.image ) ;


NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory
NSString *filePath = [documentsPath stringByAppendingPathComponent:myimageName]; //Add the file name
[pngData writeToFile:filePath atomically:YES];

Aucun commentaire:

Enregistrer un commentaire