Call the camera interface on Windows Mobile

Source: Internet
Author: User

Using the shcameracapture interface, you can call up a camera to take photos and take photos, and obtain the path of an image or video file.

Run the following code to take a photo:
Shcameracapture SHCC;
Zeromemory (& SHCC, sizeof (SHCC ));
SHCC. cbsize = sizeof (SHCC );
SHCC. hwndowner = NULL;
SHCC. pszinitialdir = NULL;
SHCC. pszdefaultfilename = NULL;
SHCC. psztitle = NULL;
SHCC. stillquality = cameracapture_stillquality_default;
SHCC. videotypes = cameracapture_videotype_all;
SHCC. nresolutionwidth = 0;
SHCC. nresolutionheight = 0;
SHCC. includeotimelimit = 0;
SHCC. mode = cameracapture_mode_still;

Hresult hreturn = shcameracapture (& SHCC );

If hreturn is s_ OK, the image is taken successfully, and SHCC. szfile is the file name (including path ). SHCC. pszinitialdir and SHCC. pszdefafilfilename can be used to set the storage path and default file name. SHCC. hwndowner may be faulty if different forms are used.

Some parameters need to be adjusted for camera recording, as shown below:
SHCC. stillquality = cameracapture_stillquality_normal;
SHCC. videotypes = cameracapture_videotype_standard;
SHCC. nresolutionwidth = 640;
SHCC. nresolutionheight = 480;
SHCC. mode = cameracapture_mode_videowithaudio;

These parameters involve several enumerated variables. Let's take a look:
Typedef Enum {
Cameracapture_mode_still = 0,
Cameracapture_mode_videoonly,
Cameracapture_mode_videowithaudio,
} Cameracapture_mode;

Cameracapture_mode_still corresponds to the photo. cameracapture_mode_videoonly corresponds to the silent video and cameracapture_mode_videowithaudio corresponds to the audio video.

Typedef Enum {
Cameracapture_stillquality_default = 0,
Cameracapture_stillquality_low,
Cameracapture_stillquality_normal,
Cameracapture_stillquality_high,
} Cameracapture_stillquality;

The corresponding image and video definition.

Typedef Enum {
Cameracapture_videotype_all = 0 xFFFF,
Cameracapture_videotype_standard = 1,
Cameracapture_videotype_messaging = 2,
} Cameracapture_videotypes;

Cameracapture_videotype_all corresponds to the photo. cameracapture_videotype_standard corresponds to the WMV Video and cameracapture_videotype_messaging corresponds to the MMS video. When the last two values are used, the nresolutionwidth and nresolutionheight of SHCC cannot be zero. It is generally 640x480.

Unfortunately, this interface can only be used at wm5.0 or above. There is no uniform camera standards in wm2003. hardware vendors can only ask the hardware vendor for calling methods.

 

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.