mirror of
https://github.com/markusfisch/BinaryEye.git
synced 2024-09-20 03:52:16 +02:00
Update CameraView library to latest version
This commit is contained in:
parent
e0c420c29f
commit
af2a1dc940
@ -18,8 +18,8 @@ android {
|
|||||||
minSdkVersion 9
|
minSdkVersion 9
|
||||||
targetSdkVersion sdk_version
|
targetSdkVersion sdk_version
|
||||||
|
|
||||||
versionCode 4
|
versionCode 5
|
||||||
versionName '1.2.1'
|
versionName '1.3.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import android.view.WindowManager;
|
|||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CameraView extends FrameLayout {
|
public class CameraView extends FrameLayout {
|
||||||
@ -183,6 +184,43 @@ public class CameraView extends FrameLayout {
|
|||||||
return frameOrientation;
|
return frameOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rect calculateFocusRect(float x, float y, int radius) {
|
||||||
|
int cx = Math.round(2000f / viewWidth * x - 1000f);
|
||||||
|
int cy = Math.round(2000f / viewHeight * y - 1000f);
|
||||||
|
return new Rect(
|
||||||
|
Math.max(-1000, cx - radius),
|
||||||
|
Math.max(-1000, cy - radius),
|
||||||
|
Math.min(1000, cx + radius),
|
||||||
|
Math.min(1000, cy + radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||||
|
public boolean setFocusArea(Rect area) {
|
||||||
|
if (camera == null || Build.VERSION.SDK_INT <
|
||||||
|
Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Camera.Parameters parameters = camera.getParameters();
|
||||||
|
if (parameters.getMaxNumFocusAreas() > 0) {
|
||||||
|
if (area != null) {
|
||||||
|
List<Camera.Area> focusAreas =
|
||||||
|
new ArrayList<Camera.Area>();
|
||||||
|
focusAreas.add(new Camera.Area(area, 1000));
|
||||||
|
parameters.setFocusAreas(focusAreas);
|
||||||
|
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
|
||||||
|
} else {
|
||||||
|
parameters.setFocusAreas(null);
|
||||||
|
CameraView.setAutoFocus(parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
camera.setParameters(parameters);
|
||||||
|
return true;
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(
|
protected void onLayout(
|
||||||
boolean changed,
|
boolean changed,
|
||||||
|
Loading…
Reference in New Issue
Block a user