mirror of
https://github.com/zxing/zxing.git
synced 2025-01-13 04:07:27 -08:00
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:
parent
033c846ec5
commit
85507c3b5d
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue