iOS Development note 17: Customizing camera photos

Source: Internet
Author: User

Before using the Avfoundation custom camera to do a photo-related things, why to customize it? The main purpose is to provide a more personalized interactive design, in line with the theme of the app, for video, but also easy to provide more rich and interesting features. The previous period of time to organize the next photo section of the function, mainly divided into the following five parts

1. Initialize, establish session, get webcam

With Avcapturesessionpresetphoto mode, the image resolution of the output is consistent with the resolution of the system camera output

Add rear camera and picture output (by default with rear camera shot)

2. Embed Live preview Layer

Get the real-time preview screen, add gestures, the default in the center of the screen focus once and display the focus frame, prompting the user to click on the screen for focus and automatic exposure adjustment.

3. Related Settings

Focus and auto exposure adjustment

Flash settings

Switch front and rear camera, _isfrontcamerainput This logo will be used in the final output processing of the captured photos, the front camera taken photos need to rotate 180 degrees

4. Capture Photos

The following points need to be noted:

(1) The view layer click on the photo button needs to be photographed when the direction of the device, the final output photos, according to the direction of the device to rotate the picture, so that the results of the final output and the system camera to capture the results of the same.

(Note: At present, through the system comes with the sensor Cmmotionmanager to obtain the direction of the device, in fact, can also be obtained through the photo metadata to the direction of information, and then do rotation processing)

(2) Add anti-shake mode, iOS8 and above system support.

(3) Get metadata information for photos taken

(4) Determine the photo clipping range, and the clipping range is the preview area. System shot gets to the photo by default is a Zhang Quan photo, but the UI design on the preview area is not full screen, in order to ensure that what you see, you need to crop the captured photos,

The preview area on the iPhone4 is a wide area of the screen (considering the size of the device, iPhone4 individually designed), and on other models, the preview area is a width-to-height ratio of 3:4 (width to screen, etc.).

(5) cutting and rotating the picture, cutting method reference: Https://github.com/mbcharbonneau/UIImage-Categories

Rotates the photo according to the device orientation information taken, and the front camera takes a photo and rotates it 180 degrees separately.

5.View Layer UI and interaction

The specific interaction design will vary according to the actual situation.

The following points need to be noted:

(1) Enter the photo screen to start the sensor monitoring, easy to capture the device orientation information, destruction needs to be closed.

(2) When switching the flash effect (on/off/auto), remember to save the user's choice and restore the setting (consistent with the system camera behavior) The next time you take a photo

iOS Development note 17: Customizing camera photos

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.