Android development skills-the Camera feature of Camera
This article summarizes how to use Camera to take photos of development projects. Camera2 is introduced in api level 21 (5.0.1), while Camera to 6.0 is still usable. Therefore, camera2 is not considered yet.
Camera in the document
Compared with the vast majority of other classes, this document provides a detailed description of Camera, including the steps required during use. Of course, this also shows that it is cumbersome to use.First, yo
, each window corresponds to a surface, so surfaceview is embedded with its own surface. We can think that surfaceview is used to control the position and size of the surface. As we all know, updates of traditional views and Their Derived classes can only be performed on the UI thread. However, the UI thread also processes other interaction logic, which cannot guarantee the view update speed and frame rate, surfaceview can be drawn using independent threads, so it can provide a higher frame rate
custom view needs to be refreshed frequently or the data processing volume is large during refresh, you can use surfaceView instead of View.
SurfaceeView has a set of templates. The following example shows how to use surfaceView to create an oscilloscope and draw a sine wave.
Package com. example. tangzh. myView; import android. content. context; import android. graphics. canvas; import android. graphics. color; import android. graphics. paint; import android. graphics. path; import android. ut
Brief introductionAlways interested in the beautiful scene of ink weather, while there is time, oneself high imitation of one of the scenes, other scenes, is similar, is mainly written object of AI is logic. Look at the effect first, the dynamic effect of the pit, too vagueHighCode AnalysisTake a look at the code structure.This uses the Surfaceview instead of the view, in fact this weather scene drawing is more like the game development, uses the surfaceview will be more flexible. Public Sc
the sample program, see Snake game.CodeFile:/samples/snake /.
Drawing on a surfaceview object
A surfaceview object is a subclass of a special view class. It provides a special graphic painting plane in the view Hierarchy Tree. The main purpose of this graphic painting surface is to provide an auxiliary thread for the application so that the application does not need to wait to complete the painting of the view Hierarchy Tree of the system. On the contrary, the auxiliary thread that referenc
1. ConceptSurfaceview is a subclass of the view class that can obtain image data directly from hardware interfaces such as memory or DMA, which is a very important drawing view. It is characterized by the ability to draw on the screen in threads other than the main thread. This prevents the main thread from being blocked when the drawing task is heavy, which improves the program's response speed. In the game development more use Surfaceview, the game background, the character, the animation and
Example of SurfaceView oscilloscope: directly add the code
The program automatically draws the sine wave and Cosine waveform on the Screen Based on the button clicked. Each time the program draws, it only needs to draw (update) the waveform of the current point. The previously drawn waveform does not need to be updated. The lockCanvas (Rect r) method of SurfaceHolder is used.
1. Layout file Layout/show_wave.xml:
[Html]Xmlns: android = "http://schemas
previewcallback, the Onpreviewframe function of Previewcallback is called whenever a frame of image data is completed. Here we convert YUV format data to JPG and enable threads to send data through the socket. public class Cameratest extends Activity {Surfaceview sview; Surfaceholder Surfaceholder; int screenwidth, screenheight; Camera camera; Defines the came
The front explained the MediaPlayer playback network audio, mainly introduced MediaPlayer about the network audio buffering and the progress bar control method, this article again explains the MediaPlayer to play the network video the method. Playing network video than playing the network audio requires a Surfaceview only, in the already familiar with the MediaPlayer play network audio, I believe that this article on the play network video can quickly grasp.
Let's take a look at this program to
> First create a view class of your own--> inherit Surfaceview and implement Surfaceholder.callback interface --> Surfaceview.getholder () to get Surfaceholder object -->surfaceholder.addcallback (callback) Add callback function -->surfaceholder.lockcanvas () Get Canvas objects and lock canvas --> canvas painting -->surfaceholder.unlockcanvasandpost (canvas canvas) end Lock and commit changes , the graphic is displayed. public class Gamesfview extends
Video Recording and playback in Android
To achieve a similar small video function, you can record a video and then play the video.
Video Recording, using a custom control.
/*** Video Recording Control ** @ author lip ** @ date 2015-3-16 */public class extends LinearLayout implements OnErrorListener {private SurfaceView mSurfaceView; private SurfaceHolder mSurfaceHolder; private ProgressBar handle; private MediaRecorder mMediaRecorder; private Camera
Use Surfaceview custom Draw big Turntable
Say not much, first on the effect chart
Full Code address Welcome start
Realization of ideas and processes
1, first understand the basic use of surfaceview, it is not the same as the general view, the use of dual caching mechanism, you can draw the view in the child thread, not because of the time to draw a loss of fluency, which is also the choice to use Surfaceview to customize this lottery big turntable reason, After all, drawing the disk block
Android cameraSeries Development (III): Taking photos through cameraapi
Author: Rain csdn blog: http://blog.csdn.net/gobitan/
Overview
There are two ways to use camera: using an existing app through intent and building your own app through camera. The intent method has been introduced in Series 1 of development. This article describes how to take photos through cameraapi.
Key classes
Several key classes need to be introduced for taking photos using cameraapi:
Camera class:The main class used to
Preparations:
1. SurfaceView
Provides a dedicated drawing surface embedded inside of a view hierarchy. you can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen
2. SurfaceHolder
Abstract interface to someone holding a display surface. Allows you to control the surface size and format, edit the pixels in the surface, and monitor changes to the surface.
Idle to have nothing to write, simple demo, the shortcomings please forgive me.PS: Some phones do not support both front and rear cameras.Add Permissions:Mainactivity.javapublic class Mainactivity extends Activity implements Onerrorlistener, Oninfolistener {Private Surfaceview Sfv1;Private Surfaceview Sfv2;Private Button btn;Private Button btn1;Private Camera Mcamera = null;Private Surfaceholder Msurfaceholder;Private
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.