public class Camera
extends java.lang.Object
For more information about the possible parameters on Windows, see: http://msdn2.microsoft.com/en-us/library/bb431794.aspx
See the CameraTest sample.
Note that you can easily rotate the image to put it in portrait mode, using the
Image.getRotatedScaledInstance
method, after retrieving the image.
To use this class with the Hand Held Dolphin barcode scanners, you must install TotalCross3/dist/vm/wince/POCKETPC/ARM/Dolphin.dll. Only 640x480 photos are supported, and you may change the following options:
In Android you can set the defaultFileName, stillQuality, resolutionWidth and resolutionHeight. All other options are ignored.
You can call the getSupportedResolutions method to see the resolutions that are available at the device.
In iOS there's no way to return the supported resolutions; it will take a photo using the default camera's resolution, and then will resize to the resolution defined in resolutionWidth/resolutionHeight, keeping the camera's aspect ratio. In iOS you can specify the defaultFileName with a path or just the name, or use a system-generated name.
In Android, you can use the internal camera by setting the cameraType field.
getSupportedResolutions()
Modifier and Type | Field and Description |
---|---|
boolean |
allowRotation
This field is false by default so that the default camera orientation is still landscape.
|
static int |
CAMERA_CUSTOM
The original camera used in TotalCross
|
static int |
CAMERA_FROM_GALLERY
Take the picture from the gallery.
|
static int |
CAMERA_NATIVE
The native camera application; a copy of the image is returned.
|
static int |
CAMERA_NATIVE_NOCOPY
The native camera application; the original image is deleted and a copy of it is returned.
|
static int |
CAMERACAPTURE_MODE_STILL
Used in the cameraMode member.
|
static int |
CAMERACAPTURE_MODE_VIDEOONLY
Used in the cameraMode member.
|
static int |
CAMERACAPTURE_MODE_VIDEOWITHAUDIO
Used in the cameraMode member.
|
static int |
CAMERACAPTURE_STILLQUALITY_DEFAULT
Used in the videoType member.
|
static int |
CAMERACAPTURE_STILLQUALITY_HIGH
Used in the videoType member.
|
static int |
CAMERACAPTURE_STILLQUALITY_LOW
Used in the videoType member.
|
static int |
CAMERACAPTURE_STILLQUALITY_NORMAL
Used in the videoType member.
|
static int |
CAMERACAPTURE_VIDEOTYPE_ALL
Used in the captureMode member.
|
static int |
CAMERACAPTURE_VIDEOTYPE_MESSAGING
Used in the captureMode member.
|
static int |
CAMERACAPTURE_VIDEOTYPE_STANDARD
Used in the captureMode member.
|
int |
cameraType
The camera type; defaults to CAMERA_CUSTOM.
|
int |
captureMode
Capture mode; defaults to STILL.
|
java.lang.String |
defaultFileName
The default file name.
|
static java.lang.String |
fcbTitle
The default title when used in desktop
|
java.lang.String |
initialDir
The initial directory.
|
int |
resolutionHeight
The height for the resolution
|
int |
resolutionWidth
The width for the resolution
|
int |
stillQuality
The still quality.
|
java.lang.String |
title
The title to display in the window.
|
int |
videoTimeLimit
Maximum time limit for recording a video.
|
int |
videoType
Video type; defaults to ALL.
|
Constructor and Description |
---|
Camera() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
click()
Takes a photo based on the members set.
|
protected void |
finalize() |
static java.lang.String[] |
getSupportedResolutions()
Returns the resolutions that are supported by the device.
|
public java.lang.String initialDir
public java.lang.String defaultFileName
public java.lang.String title
public int stillQuality
public int videoType
public int resolutionWidth
public int resolutionHeight
public int videoTimeLimit
public int captureMode
public boolean allowRotation
public int cameraType
public static final int CAMERA_CUSTOM
public static final int CAMERA_NATIVE
public static final int CAMERA_NATIVE_NOCOPY
public static final int CAMERA_FROM_GALLERY
public static final int CAMERACAPTURE_MODE_STILL
public static final int CAMERACAPTURE_MODE_VIDEOONLY
public static final int CAMERACAPTURE_MODE_VIDEOWITHAUDIO
public static final int CAMERACAPTURE_STILLQUALITY_DEFAULT
public static final int CAMERACAPTURE_STILLQUALITY_LOW
public static final int CAMERACAPTURE_STILLQUALITY_NORMAL
public static final int CAMERACAPTURE_STILLQUALITY_HIGH
public static final int CAMERACAPTURE_VIDEOTYPE_ALL
public static final int CAMERACAPTURE_VIDEOTYPE_STANDARD
public static final int CAMERACAPTURE_VIDEOTYPE_MESSAGING
public static java.lang.String fcbTitle
public java.lang.String click() throws IOException
IOException
- if any other error occurs.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public static java.lang.String[] getSupportedResolutions()
When the information is not available, a default list is returned and the first element is set to "Default values:".
If you take a photo and an image with a different resolution is returned, its because the selected resolution is not supported by the device.
Values are always in LANDSCAPE.