-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
imageView.image = image;
NSData *pngImage = UIImagePNGRepresentation(image);
if([pngImage writeToFile:[NSString stringWithFormat:@"%@/tempImage.png",
TEMP_FOLDER] atomically:YES]){
UIImage *myThumbNail = [[UIImage alloc] initWithData:pngImage];
UIGraphicsBeginImageContext(CGSizeMake(60.0,60.0));
[myThumbNail drawInRect:CGRectMake(0.0, 0.0, 60.0, 60.0)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *thumbView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 60.0, 60.0)];
thumbView.image = newImage;
[self.view addSubview:thumbView];
NSData *thumbData = UIImagePNGRepresentation(newImage);
if([thumbData writeToFile:[NSString stringWithFormat:@"%@/tempImageThumb.png", TEMP_FOLDER] atomically:YES]){
NSLog(@"thumb written!");
}
[picker dismissModalViewControllerAnimated:YES];
}else{
NSLog(@" there was an error writing the file to the temp directory");
}
}
No comments:
Post a Comment