Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How to resize a image when save photo in document folder ???

This is how I save an image in iphone.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imageFile = nil;
NSString *name_png = [NSString stringWithFormat:@"%@.png",photoName];
imageFile = [documentsDirectory stringByAppendingPathComponent:name_png];
[UIImagePNGRepresentation(self.theImageView.image) writeToFile:imageFile atomically:YES];

How to resize it from original size to 200 X 200 pixels?

Or can I load the image file than resize it?

Actually, I was create a cover flow with many images, and the image was from camera.

I can find a cover flow sample, but when I load image, it full of iphone screen.

Not a small cover image.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.9k views
Welcome To Ask or Share your Answers For Others

1 Answer

UIImage resize : Go thru this link.

Thanks to Paul Lynch.

+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
    UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
    [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();    
    UIGraphicsEndImageContext();
    return newImage;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...