de.enough.polish.snapshot
Class SnapshotUtil

java.lang.Object
  extended by de.enough.polish.snapshot.SnapshotUtil
Direct Known Subclasses:
CameraUtil

public class SnapshotUtil
extends Object


Constructor Summary
SnapshotUtil()
           
 
Method Summary
static int getCameraMountPosition()
          Retrieves the position of the camera.
static CameraResolution getDefaultResolution()
          Retrieves the default resolution.
static String getProtocol()
          Returns the protocol to capture an image
static String[] getSnapshotEncodings()
          Retrieves the supported snapshot encodings available on the current device.
static String[] getSnapshotEncodingsWithResolutionCloseTo(int width, int height)
          Determines the best fitting encoding for reaching snapshots of at least the specified dimensions
static String[] getSnapshotEncodingsWithResolutionCloseTo(int width, int height, boolean needsToBeLarger, boolean needsToBeSmaller, String format)
          Determines the best fitting encoding
static String[] getSnapshotFormats()
          Tries to determine the available formats from the supported encodings
static CameraResolution[] getSnapshotResolutions()
          Tries to determine the available resolutions from the supported encodings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnapshotUtil

public SnapshotUtil()
Method Detail

getProtocol

public static String getProtocol()
                          throws MediaException
Returns the protocol to capture an image

Returns:
the protocol string
Throws:
MediaException - if capture is not supported

getCameraMountPosition

public static int getCameraMountPosition()
Retrieves the position of the camera.

Returns:
either portrait, landscape or unknown
See Also:
MOUNT_POSITION_LANDSCAPE, MOUNT_POSITION_PORTRAIT, MOUNT_POSITION_UNKNOWN

getSnapshotEncodings

public static String[] getSnapshotEncodings()
Retrieves the supported snapshot encodings available on the current device.

Returns:
an array of encodings. When the "video.snapshot.encodings" system property is null, an empty array is returned.

getSnapshotResolutions

public static CameraResolution[] getSnapshotResolutions()
Tries to determine the available resolutions from the supported encodings

Returns:
an array of detected resolutions, may be empty but not null. Each resolution is returned as a Point object, where x defines the width and y defines the height of the resolution.

getDefaultResolution

public static CameraResolution getDefaultResolution()
Retrieves the default resolution.

Returns:
the default resolution as a point object - x represents the width, y the height. This can be null if no resolution is specified in "video.snapshot.encodings"!

getSnapshotEncodingsWithResolutionCloseTo

public static String[] getSnapshotEncodingsWithResolutionCloseTo(int width,
                                                                 int height)
Determines the best fitting encoding for reaching snapshots of at least the specified dimensions

Parameters:
width - the minimum width, e.g. 800
height - the minum height, e.g. 640
Returns:
an array of suitable encodings, when format is specified this will typically only contain one element; the array will be empty (but not null) when no suitable encoding is found

getSnapshotEncodingsWithResolutionCloseTo

public static String[] getSnapshotEncodingsWithResolutionCloseTo(int width,
                                                                 int height,
                                                                 boolean needsToBeLarger,
                                                                 boolean needsToBeSmaller,
                                                                 String format)
Determines the best fitting encoding

Parameters:
format - the format, e.g. jpg
width - the desired width, e.g. 800
height - the desired height, e.g. 640
needsToBeLarger - true when the found encodings needs to be the same size or larger than the specified dimensions
needsToBeSmaller - true when the found encodings needs to be the same size or smaller than the specified dimensions
Returns:
an array of suitable encodings, when format is specified this will typically only contain one element; the array will be empty (but not null) when no suitable encoding is found

getSnapshotFormats

public static String[] getSnapshotFormats()
Tries to determine the available formats from the supported encodings

Returns:
an array of detected formats (in lower case), may be emtpy but not null