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 > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 06-07-2011, 10:54 PM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 23
tmeehan is on a distinguished road
Default UIImagePicker how to get the preview rect match the actual image

In the UIImagePicker, when taking a picture, the full 320 x 480 preview image is the image that will be captured when the picture is taken. so when you have a custom overlay with a tool bar with buttons at the bottom (like the camera app has), the tool bar obstructs part of the preview. But the actual photo taken will include the stuff that was under the tool bar in the preview.

I notice that that is not the case with the camera app. somehow it resizes the preview so the area under the tool bar is not part of the picture. But in all the sample code I've found, the area under the tool bar is part of the picture that gets taken. I would have assumed that the preview view was scaled down so that the 320 x 480 picture area was now ??? x 440 (or what ever the screen height minus the toolbar height is). I would also have assumed that the 320 dimension would be scaled as well to keep the aspect ratio correct. But it seems that the full 320 screen width is in the picture but somehow the height is scaled or something like that.

The question is : How do I get the preview view to show exactly what's going to be in the picture and not have any of it obstructed by the tool bar.

Any clues would be greatly appreciated. thanks.
tmeehan is offline   Reply With Quote
Old 06-13-2011, 02:35 AM   #2 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default

So in your case the uiimageview in the background has the full height of the screen, 480. At the bottom you have the toolbar on top of your imageview. You need to shorten your imageview so that the height of your imageview + height of toolbar = 480 (or 460 if the top bar is visible...).

In order to keep aspect ration you need to set Aspect Fit in your imageview.
Code:
imageView.contentMode = UIViewContentModeScaleAspectFit;
This will probably leave black bars on either top or sides but this will ensure you see the whole photo, correct aspect ratio. You may want to look in to aspect fill as well as it's the prettier option.
sneaky is offline   Reply With Quote
Reply

Bookmarks

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: 385
18 members and 367 guests
Absentia, AyClass, Diligent, dre, fvisticot, givensur, jbro, jPuzzle, momolgtm, Newbie123, Paul10, Punkjumper, revg, sacha1996, skrew88, taylor202, tomtom100
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,643
Threads: 94,110
Posts: 402,858
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Diligent
Powered by vBadvanced CMPS v3.1.0

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