Reputation: 171
i am new developer on iphone.in my application i take 1button,1imageview and pickercontrol.
i want to access images from photoalbum,display that image and store that image in sqlite database.i completed till image display but i don't no how store indatabase and another problem is while access images from photolibrary we have to reduce the size of image with out affecting on clarity(reduce pixel size compare with real image).and reduce memory size in database.
This is my code
- (void)viewDidLoad {
self.picker = [[UIImagePickerController alloc] init];
self.picker.allowsImageEditing = YES;
self.picker.delegate = self;
self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[super viewDidLoad];
}
-(IBAction)selectimage{
[self presentModalViewController:self.picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
image.image = img;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
Upvotes: 0
Views: 643
Reputation: 14419
I strongly suggest using files for caching images (and more generally for caching large files)... ;)
...and store the path/filename in database... Even if there is a way to store such blobs in sqlite, that would probably a potential performance bottleneck.
To reduce image sizes, you can easily compress to JPEG using UIImageJPEGRepresentation
.
Upvotes: 1
Reputation: 47241
I strongly suggest using Core Data, so you don't have to care for how persisting of images/data has to be implemented.
Upvotes: 0