public final class CameraManager
extends java.lang.Object
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
CameraManager.OnSensorListener
传感器灯光亮度监听
|
static interface |
CameraManager.OnTorchListener |
| 构造器和说明 |
|---|
CameraManager(Context context) |
| 限定符和类型 | 方法和说明 |
|---|---|
com.google.zxing.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.
|
Point |
getCameraResolution() |
Rect |
getFramingRect()
Calculates the framing rect which the UI should draw to show the user where to place the
barcode.
|
Rect |
getFramingRectInPreview()
Like
getFramingRect() but coordinates are in terms of the preview frame,
not UI / screen. |
OpenCamera |
getOpenCamera() |
Point |
getScreenResolution() |
boolean |
isOpen() |
void |
openDriver(SurfaceHolder holder)
Opens the camera driver and initializes the hardware parameters.
|
void |
requestPreviewFrame(Handler handler,
int message)
A single preview frame will be returned to the handler supplied.
|
void |
sensorChanged(boolean tooDark,
float ambientLightLux) |
void |
setFramingRectHorizontalOffset(int framingRectHorizontalOffset) |
void |
setFramingRectRatio(float framingRectRatio) |
void |
setFramingRectVerticalOffset(int framingRectVerticalOffset) |
void |
setFullScreenScan(boolean fullScreenScan) |
void |
setManualCameraId(int cameraId)
Allows third party apps to specify the camera ID, rather than determine
it automatically based on available cameras and their orientation.
|
void |
setManualFramingRect(int width,
int height)
Allows third party apps to specify the scanning rectangle dimensions, rather than determine
them automatically based on screen resolution.
|
void |
setOnSensorListener(CameraManager.OnSensorListener listener)
传感器光线照度监听
|
void |
setOnTorchListener(CameraManager.OnTorchListener listener)
提供闪光灯监听
|
void |
setTorch(boolean newSetting)
Convenience method for
CaptureActivity |
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 void openDriver(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 boolean isOpen()
public OpenCamera getOpenCamera()
public void closeDriver()
public void startPreview()
public void stopPreview()
public void setTorch(boolean newSetting)
CaptureActivitynewSetting - if true, light should be turned on if currently off. And vice versa.public void requestPreviewFrame(Handler handler,
int message)
handler - The handler to send the message to.message - The what field of the message to be sent.public Rect getFramingRect()
public Rect getFramingRectInPreview()
getFramingRect() but coordinates are in terms of the preview frame,
not UI / screen.Rect expressing barcode scan area in terms of the preview sizepublic void setFullScreenScan(boolean fullScreenScan)
public void setFramingRectRatio(float framingRectRatio)
public void setFramingRectVerticalOffset(int framingRectVerticalOffset)
public void setFramingRectHorizontalOffset(int framingRectHorizontalOffset)
public Point getCameraResolution()
public Point getScreenResolution()
public void setManualCameraId(int cameraId)
cameraId - camera ID of the camera to use. A negative value means "no preference".public void setManualFramingRect(int width,
int height)
width - The width in pixels to scan.height - The height in pixels to scan.public com.google.zxing.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 void setOnTorchListener(CameraManager.OnTorchListener listener)
listener - public void setOnSensorListener(CameraManager.OnSensorListener listener)
listener - public void sensorChanged(boolean tooDark,
float ambientLightLux)