Android auto-focus photography

Source: Internet
Author: User

Android style and theme)

 

In Android, a topic is used to define the display style for an application. Its definition is the same as that for a style, as shown below:

<? Xmlversion = "1.0" encoding = "UTF-8"?>

<Resources>

<Stylename = "itcasttheme">

<Item name = "Android: windownotitle"> true </item> <! -No title.

<Item name = "Android: windowfullscreen">? Android: windownotitle </item> <! -Full Screen Display (à)

</Style>

</Resources>

Above "? The question mark in Android: windownotitle is used to reference the resource value defined in the current topic. The following code shows how to set the topic defined above in androidmanifest. xml:

<Applicationandroid: icon = "@ drawable/icon" Android: Label = "@ string/app_name"

Android: theme = "@ style/itcasttheme">

......

</Application>

In addition to setting a topic in androidmanifest. XML, you can also set a topic in the Code as follows:

Settheme (R. style.Itcasttheme );

 

 

Camera = camera.Open();

Windowmanager WM = (windowmanager) getsystemservice (context.Window_service);

DisplayDisplay= WM. getdefaultdisplay ();

Camera. parametersparameters = camera. getparameters ();

Parameters. setpreviewsize (320,240); // you can specify the preview size.

// Parameters. setpreviewframerate (3); // three frames per second

Parameters. setpictureformat (pixelformat.JPEG); // Set the photo output format

Parameters. Set ("Jpeg-quality", 85); // photo quality

Parameters. setpicturesize (320,240); // you can specify the Photo size.

Camera. setparameters (parameters );

Camera. setpreviewdisplay (surfaceview. getholder (); // you can use surfaceview to view the video.

Camera. startpreview (); // start previewing

 

 

 

Camera. autofocus (null); // auto focus

 

Photo response

Private final classTakepicturecallback
Implements
Picturecallback {

@ Override

Public voidOnpicturetaken (Byte[] Data, camera ){

Try{

Bitmap bitmap = bitmapfactory.Decodebytearray(Data, 0, Data. Length );

File file =NewFile (environment.Getexternalstoragedirectory(), System.Currenttimemillis() + ". Jpg ");

Fileoutputstream outstream =NewFileoutputstream (File );

Bitmap. Compress (compressformat.JPEG, 100, outstream );

Outstream. Close ();

Camera. stoppreview ();

Camera. startpreview (); // start previewing

}Catch(Exception e ){

Log.E(Tag, E. tostring ());

}

}

}

Related Article

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.