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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 11-22-2009, 05:44 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Colombo, Sri Lanka
Posts: 58
Send a message via Yahoo to tharindufit Send a message via Skype™ to tharindufit
Question How to get smaller square size image picked from UIImagePickerController

Hi

I am trying to get a thumb image that is croped to a 64X64 rectangle usinng UIImagePickerController. What I need is something like thumb square image available in UIImagePickerController photo libraries. Could anyone give some method or hints on how to achieve this ?

Thank you,
Tharindu
tharindufit is offline   Reply With Quote
Old 11-22-2009, 01:58 PM   #2 (permalink)
Will Work for Food!
 
itzdark's Avatar
 
Join Date: Apr 2009
Posts: 579
Send a message via AIM to itzdark Send a message via MSN to itzdark
Default

Code:
//resize image
	CGSize newSize = CGSizeMake(40, 40);
	UIGraphicsBeginImageContext( newSize );
	[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
	UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
__________________

Check out my apps

Developers, check out study buddy. I use it everytime I code. It's great for those late night coding sessions.
Unofficial Ad Hoc Distribution Guide || Join my cooperative ad hoc testing group
iSoothe Promotional Video
Contact Me
itzdark is offline   Reply With Quote
Old 11-22-2009, 08:16 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Colombo, Sri Lanka
Posts: 58
Send a message via Yahoo to tharindufit Send a message via Skype™ to tharindufit
Default

Quote:
Originally Posted by itzdark View Post
Code:
//resize image
	CGSize newSize = CGSizeMake(40, 40);
	UIGraphicsBeginImageContext( newSize );
	[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
	UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
But will this make image disordered or something. I mean width and height may different in an image I might be picking. So how does iPhone Photos application make thumbnails ?

Thanks
tharindufit is offline   Reply With Quote
Old 11-24-2009, 04:38 PM   #4 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 7
Default

Quote:
Originally Posted by tharindufit View Post
But will this make image disordered or something. I mean width and height may different in an image I might be picking. So how does iPhone Photos application make thumbnails ?

Thanks
Also, does this, or is there a way to reduce the image file size? I get an image from the library and if its too big it taeks awhile for the ImageView to display it.

Thanks!!
JonnyBGoode is offline   Reply With Quote
Old 11-24-2009, 08:15 PM   #5 (permalink)
jsd
at this moment
 
Join Date: Mar 2009
Location: San Francisco, CA
Posts: 900
Default

Quote:
Originally Posted by JonnyBGoode View Post
Also, does this, or is there a way to reduce the image file size? I get an image from the library and if its too big it taeks awhile for the ImageView to display it.

Thanks!!
The code listed above will also fail if the image was taken with the phone in any orientation other than landscape left. You need to (possibly) rotate the image, then resize it proportionally. You can then stick it in a square imageview and cut off the sides as needed. You can create a square imageview, set it's contentMode to UIViewContentModeScaleAspectFill and clipsToBounds to YES.
jsd is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, thumb, uiimage, uiimagepickercontroller

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: 279
25 members and 254 guests
ADY, AragornSG, Bertrand21, Dani77, Dattee, fkmtc, HDshot, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, jimbo, macquitzon216, mer10, NSeven, prchn4christ, Rudy, sacha1996, silverwiz, sneaky, spiderguy84, Sunny46, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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