public final class CameraManager
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
FRAME_HEIGHT |
static int |
FRAME_MARGINTOP |
static int |
FRAME_WIDTH |
| 限定符和类型 | 方法和说明 |
|---|---|
PlanarYUVLuminanceSource |
buildLuminanceSource(byte[] data,
int width,
int height)
A factory method to build the appropriate LuminanceSource object based on the format
of the preview buffers, as described by Camera.Parameters.
|
void |
closeDriver()
Closes the camera driver if still in use.
|
static CameraManager |
get()
Gets the CameraManager singleton instance.
|
AutoFocusCallback |
getAutoFocusCallback() |
android.hardware.Camera |
getCamera() |
android.content.Context |
getContext() |
android.graphics.Rect |
getFramingRect()
Calculates the framing rect which the UI should draw to show the user where to place the
barcode.
|
android.graphics.Rect |
getFramingRectInPreview()
Like
getFramingRect() but coordinates are in terms of the preview frame,
not UI / screen. |
PreviewCallback |
getPreviewCallback() |
static void |
init(android.content.Context context)
Initializes this static object with the Context of the calling Activity.
|
boolean |
isPreviewing() |
boolean |
isUseOneShotPreviewCallback() |
void |
openDriver(android.view.SurfaceHolder holder)
Opens the camera driver and initializes the hardware parameters.
|
void |
requestAutoFocus(android.os.Handler handler,
int message)
Asks the camera hardware to perform an autofocus.
|
void |
requestPreviewFrame(android.os.Handler handler,
int message)
A single preview frame will be returned to the handler supplied.
|
void |
setPreviewing(boolean previewing) |
void |
startPreview()
Asks the camera hardware to begin drawing preview frames to the screen.
|
void |
stopPreview()
Tells the camera to stop drawing preview frames.
|
public static int FRAME_WIDTH
public static int FRAME_HEIGHT
public static int FRAME_MARGINTOP
public static void init(android.content.Context context)
context - The Activity which wants to use the camera.public static CameraManager get()
public void openDriver(android.view.SurfaceHolder holder)
throws java.io.IOException
holder - The surface object which the camera will draw preview frames into.java.io.IOException - Indicates the camera driver failed to open.public void closeDriver()
public void startPreview()
public void stopPreview()
public void requestPreviewFrame(android.os.Handler handler,
int message)
handler - The handler to send the message to.message - The what field of the message to be sent.public void requestAutoFocus(android.os.Handler handler,
int message)
handler - The Handler to notify when the autofocus completes.message - The message to deliver.public android.graphics.Rect getFramingRect()
public android.graphics.Rect getFramingRectInPreview()
getFramingRect() but coordinates are in terms of the preview frame,
not UI / screen.public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height)
data - A preview frame.width - The width of the image.height - The height of the image.public android.content.Context getContext()
public android.hardware.Camera getCamera()
public boolean isPreviewing()
public boolean isUseOneShotPreviewCallback()
public PreviewCallback getPreviewCallback()
public AutoFocusCallback getAutoFocusCallback()
public void setPreviewing(boolean previewing)