mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
"Regular" version now attempts to set desired camera exposure settings
git-svn-id: https://zxing.googlecode.com/svn/trunk@310 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
3a1e3dc156
commit
7813847052
|
@ -17,7 +17,6 @@
|
||||||
package com.google.zxing.client.j2me;
|
package com.google.zxing.client.j2me;
|
||||||
|
|
||||||
import javax.microedition.media.Controllable;
|
import javax.microedition.media.Controllable;
|
||||||
import javax.microedition.media.MediaException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>See this exact same class under the "src" source root for a full explanation.
|
* <p>See this exact same class under the "src" source root for a full explanation.
|
||||||
|
@ -34,7 +33,7 @@ final class AdvancedMultimediaManager {
|
||||||
|
|
||||||
// These signatures must match those in the other class exactly
|
// These signatures must match those in the other class exactly
|
||||||
|
|
||||||
static void setFocus(Controllable player) throws MediaException {
|
static void setFocus(Controllable player) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,4 +41,8 @@ final class AdvancedMultimediaManager {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setExposure(Controllable player) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.google.zxing.client.j2me;
|
package com.google.zxing.client.j2me;
|
||||||
|
|
||||||
|
import javax.microedition.amms.control.camera.ExposureControl;
|
||||||
import javax.microedition.amms.control.camera.FocusControl;
|
import javax.microedition.amms.control.camera.FocusControl;
|
||||||
import javax.microedition.amms.control.camera.ZoomControl;
|
import javax.microedition.amms.control.camera.ZoomControl;
|
||||||
import javax.microedition.media.Controllable;
|
import javax.microedition.media.Controllable;
|
||||||
|
@ -38,30 +39,31 @@ final class AdvancedMultimediaManager {
|
||||||
private static final int NO_ZOOM = 100;
|
private static final int NO_ZOOM = 100;
|
||||||
private static final int MAX_ZOOM = 200;
|
private static final int MAX_ZOOM = 200;
|
||||||
private static final long FOCUS_TIME_MS = 750L;
|
private static final long FOCUS_TIME_MS = 750L;
|
||||||
|
private static final String DESIRED_METERING = "center-weighted";
|
||||||
|
|
||||||
private AdvancedMultimediaManager() {
|
private AdvancedMultimediaManager() {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setFocus(Controllable player) throws MediaException {
|
static void setFocus(Controllable player) {
|
||||||
FocusControl focusControl = (FocusControl)
|
FocusControl focusControl = (FocusControl)
|
||||||
player.getControl("javax.microedition.amms.control.camera.FocusControl");
|
player.getControl("javax.microedition.amms.control.camera.FocusControl");
|
||||||
if (focusControl != null) {
|
if (focusControl != null) {
|
||||||
if (focusControl.isMacroSupported() && !focusControl.getMacro()) {
|
try {
|
||||||
focusControl.setMacro(true);
|
if (focusControl.isMacroSupported() && !focusControl.getMacro()) {
|
||||||
}
|
focusControl.setMacro(true);
|
||||||
if (focusControl.isAutoFocusSupported()) {
|
|
||||||
focusControl.setFocus(FocusControl.AUTO);
|
|
||||||
try {
|
|
||||||
Thread.sleep(FOCUS_TIME_MS); // let it focus...
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
// continue
|
|
||||||
}
|
}
|
||||||
try {
|
if (focusControl.isAutoFocusSupported()) {
|
||||||
|
focusControl.setFocus(FocusControl.AUTO);
|
||||||
|
try {
|
||||||
|
Thread.sleep(FOCUS_TIME_MS); // let it focus...
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
// continue
|
||||||
|
}
|
||||||
focusControl.setFocus(FocusControl.AUTO_LOCK);
|
focusControl.setFocus(FocusControl.AUTO_LOCK);
|
||||||
} catch (MediaException me) {
|
|
||||||
// continue; some phones like the SE K850 don't support this?
|
|
||||||
}
|
}
|
||||||
|
} catch (MediaException me) {
|
||||||
|
// continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,4 +86,37 @@ final class AdvancedMultimediaManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setExposure(Controllable player) {
|
||||||
|
ExposureControl exposureControl =
|
||||||
|
(ExposureControl) player.getControl("javax.microedition.amms.control.camera.ExposureControl");
|
||||||
|
if (exposureControl != null) {
|
||||||
|
|
||||||
|
int[] supportedISOs = exposureControl.getSupportedISOs();
|
||||||
|
if (supportedISOs != null && supportedISOs.length > 0) {
|
||||||
|
int maxISO = Integer.MIN_VALUE;
|
||||||
|
for (int i = 0; i < supportedISOs.length; i++) {
|
||||||
|
if (supportedISOs[i] > maxISO) {
|
||||||
|
maxISO = supportedISOs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
exposureControl.setISO(maxISO);
|
||||||
|
} catch (MediaException me) {
|
||||||
|
// continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] supportedMeterings = exposureControl.getSupportedLightMeterings();
|
||||||
|
if (supportedMeterings != null) {
|
||||||
|
for (int i = 0; i < supportedMeterings.length; i++) {
|
||||||
|
if (DESIRED_METERING.equals(supportedMeterings[i])) {
|
||||||
|
exposureControl.setLightMetering(DESIRED_METERING);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -71,6 +71,7 @@ public final class ZXingMIDlet extends MIDlet {
|
||||||
player = createPlayer();
|
player = createPlayer();
|
||||||
player.realize();
|
player.realize();
|
||||||
AdvancedMultimediaManager.setZoom(player);
|
AdvancedMultimediaManager.setZoom(player);
|
||||||
|
AdvancedMultimediaManager.setExposure(player);
|
||||||
videoControl = (VideoControl) player.getControl("VideoControl");
|
videoControl = (VideoControl) player.getControl("VideoControl");
|
||||||
canvas = new VideoCanvas(this);
|
canvas = new VideoCanvas(this);
|
||||||
canvas.setFullScreenMode(true);
|
canvas.setFullScreenMode(true);
|
||||||
|
|
Loading…
Reference in a new issue