에 저장 나는 resize the image,</p> <p>을있는 UIImage의 크기를 조정하고 내가있는 UIImage의 크기를 조정하고 내 응용 프로그램 파일 시스템에 저장해야 내 응용 프로그램 파일 시스템
하거나이를위한 작은 cgrect로 표시 할 수 있습니다 프레임,
하지만이 새로 크기가 조정 된 이미지를 내 앱 파일 sys에 저장할 수 있습니까?
감사합니다.
에 저장 나는 resize the image,</p> <p>을있는 UIImage의 크기를 조정하고 내가있는 UIImage의 크기를 조정하고 내 응용 프로그램 파일 시스템에 저장해야 내 응용 프로그램 파일 시스템
하거나이를위한 작은 cgrect로 표시 할 수 있습니다 프레임,
하지만이 새로 크기가 조정 된 이미지를 내 앱 파일 sys에 저장할 수 있습니까?
감사합니다.
는 이미지가
//Where the 0 denotes the compression (0 to 1).
NSData *imageData = UIImageJPEGRepresentation(image, 0);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"MyImageFolder"];
NSError *error;
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]; //Create folder
NSString *fullPath = [dataPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg", imageName]]; //add our image to the path
bool successI = [imageData writeToFile:fullPath atomically:YES];
if (successI) {
// NSLog(@"Image saved correctly");
} else
NSLog(@"Error while saving Image");
언급하고 잊어 버렸 이미지라고 가정하면, 당신은 다른 곳에 저장하는
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
을 변경할 수 있습니다.
먼저 다음 앱에서 문서 또는 라이브러리 폴더에 데이터를 기록
UIImageJPEGRepresentation
또는
UIImagePNGRepresentation
가있는 NSData에있는 UIImage을 변환 할 수 있습니다.