3Dcompass© (augmented reality) 0.8.5 - fit camera preview to fullscreen
There were little trick to do during the scaling of the camera preview mentioned in the previous post. The only way to transform the camera preview is to assign a CGAffineTransform to the UIImagePickerController's cameraViewTransform property.
Knowing that the camera view (320x427) gets scaled from its center as a pivot point, it needs to be adjusted vertically since it is aligned top initially (its frame is 0,0,320,427). Thus we have to do a scale, and a translate in one step (must define it in one single CGAffineTransform matrix).
As I realized the camera preview has to be scaled to 480/427 and shifted down by (480-427)/2 to fit the entire screen (with a slight 6% crop by each side).
As I read the CGAffineTransform description carefully, and planned the transformation carefully above, creating the matrix wasn't a big deal (thanks for OpenGL to introducing me the idea of matrices). As the device/camera has fixed dimensions, we can calculate the constants to work with, the code goes below.
#define kCameraScale 1.12412178 //= 480 / 427 #define kCameraOffset 26.5 //= (480 - 427) / 2 //Make camera view full screen. picker.wantsFullScreenLayout = YES; picker.cameraViewTransform = CGAffineTransformMake(kCameraScale, 0.0f, 0.0f, kCameraScale, 0.0f, kCameraOffset);
It gives a pretty fullscreen camera preview with only a 12% zoom and without any distortion. It crops only 6% on each side, and there is no offset relative to the OpenGL overlay now.
Tomorrow I'm gonna do some interface/design/marketing stuff. As the app 3Dcompass© will be completed soon it needs a coherent identy.
Not commented yet.
HTML tags not allowed, URL-s underlined automatically. An e-mail is minimum required (it wont appear on the page).If you have a freeblog account, may log in here.
All the things behind
iPhone game development. Flash (ActionScript), iPhone (xCode, Objective-C, Cocoa-Touch), augmented reality, geometry, user-experience, tangram, sudoku, origami, whatever.
iPhone Apps- compass3D©
All categories- Archive from old times (hungarian) (10)
- compactSudoku© (20)
- compactTangram© (48)
- compass3D© (24)
- Creativity (3)
- gotoandplay.freeblog.hu (2)
- Origami sessions (2)
- Sudoku technikák (3)
- TapStack© (7)
- xCode - augmented reality (28)
- xCode - hasznos linkek (1)
- xCode - iPhone app development (92)
- xCode - OpenGL ES 1.x for iPhone (27)