Try to do a better job of understanding if the phone supports video capture, and what formats, to provide better errors when it won't work

git-svn-id: https://zxing.googlecode.com/svn/trunk@889 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-03-11 21:43:04 +00:00
parent 033c846ec5
commit 85507c3b5d

View file

@ -91,10 +91,31 @@ final class SnapshotThread implements Runnable {
}
private byte[] takeSnapshot() throws MediaException {
// Check this property, present on some Nokias?
String supportsVideoCapture = System.getProperty("supports.video.capture");
if ("false".equals(supportsVideoCapture)) {
throw new MediaException("supports.video.capture is false");
}
String bestEncoding = null;
String videoSnapshotEncodings = System.getProperty("video.snapshot.encodings");
if (videoSnapshotEncodings != null) {
// We know explicitly what the camera supports; see if PNG is among them since
// Image.createImage() should always support it
int pngEncodingStart = videoSnapshotEncodings.indexOf("encoding=png");
if (pngEncodingStart >= 0) {
int space = videoSnapshotEncodings.indexOf(' ', pngEncodingStart);
bestEncoding = space >= 0 ?
videoSnapshotEncodings.substring(pngEncodingStart, space) :
videoSnapshotEncodings.substring(pngEncodingStart);
}
}
VideoControl videoControl = zXingMIDlet.getVideoControl();
byte[] snapshot = null;
try {
snapshot = videoControl.getSnapshot(null);
snapshot = videoControl.getSnapshot(bestEncoding);
} catch (MediaException me) {
}
if (snapshot == null) {