画像サイズの調整(拡大縮小)つづき
画像の表示サイズを変える方法はいろいろあるが、画像自体のサイズを変える方法をとることにする。
- (void)imagePickerController:(UIImagePickerController *) picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self dismissViewControllerAnimated:YES completion:nil]; UIImage *img = [info objectForKey: UIImagePickerControllerOriginalImage]; UIImage *img_aft; float scale = self.view.bounds.size.width/img.size.width; NSLog(@"<%f>", xscale); CGSize sz = CGSizeMake(img.size.width*scale, img.size.height*scale); UIGraphicsBeginImageContext(sz); [img drawInRect:CGRectMake(0,0,sz.width,sz.height)]; img_aft = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); iv.image = img_aft; }