Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-07-2011, 04:37 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 25
BarryK88 is on a distinguished road
Default How to set the resolution of a saved image from the UIImagePickerController.

I'm using an UIImagePickerController to set a picture from my cameraroll to a UIImageView. However the image is getting scaled automaticly inside this UIImageView because I mentioned 'scale to fit' inside the IB. I'd like to save my chosen image with a resolution of 80x80 pixels so that I won't have to scale. (My App is getting realy slow because of this scaling issue.)

Here's a snippit from my code:

Code:
-(void)imagePickerController:(UIImagePickerController *)picker
    	  didFinishPickingImage : (UIImage *)image
    				 editingInfo:(NSDictionary *)editingInfo
    {
    	[picker dismissModalViewControllerAnimated:YES];
    	UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
    		photoView.image = image;
    	
    
    		NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];		
    		NSString *pngFilePath = [NSString stringWithFormat:@"%@/foto1.png",docDir];
    		NSData *data = [NSData dataWithData:UIImagePNGRepresentation(image)];
    		
    		[data writeToFile:pngFilePath atomically:YES];
    }
Help is greatly appreciated!
BarryK88 is offline   Reply With Quote
Old 04-07-2011, 11:10 AM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Use UIGraphicsBeginImageContextWithOptions to create a new context of the size you want, then use the drawInRect method of the UIImage to draw it in the same rect size, then use UIGraphicsGetImageFromCurrentImageContext to grab the resulting, scaled down UIImage.
baja_yu is offline   Reply With Quote
Reply

Bookmarks

Tags
save, scale, uiimagepickercontroller, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 365
12 members and 353 guests
dansparrow, dre, ilmman, LezB44, michelle, Nobbsy, Objective Zero, samdanielblr, Sami Gh, shagor012, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:41 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0