本文整理汇总了Java中android.hardware.Camera.Size类的典型用法代码示例。如果您正苦于以下问题:Java Size类的具体用法?Java Size怎么用?Java Size使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Size类属于android.hardware.Camera包,在下文中一共展示了Size类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCameraInfo
import android.hardware.Camera.Size; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public WritableMap getCameraInfo(int index) {
CameraInfo info = new CameraInfo();
Size size = null;
try {
Camera.getCameraInfo(index, info);
Camera camera = Camera.open(index);
size = getMaxSupportedVideoSize(camera);
camera.release();
} catch (Exception var3) {
Logging.e("CameraEnumerationAndroid", "getCameraInfo failed on index " + index, var3);
return null;
}
WritableMap params = Arguments.createMap();
String facing = info.facing == 1 ? "front" : "back";
params.putString("label", "Camera " + index + ", Facing " + facing + ", Orientation " + info.orientation);
params.putString("id", "" + index);
params.putString("facing", facing);
params.putString("kind", "video");
params.putString("maxWidth", String.valueOf(size.width));
params.putString("maxHeight", String.valueOf(size.height));
return params;
}
示例2: configPreviewSize2
import android.hardware.Camera.Size; //导入依赖的package包/类
public BarcodeCameraConfig configPreviewSize2(int viewWidth, int viewHeight) {
Parameters params = camera.getParameters();
List<Size> sizes = params.getSupportedPreviewSizes();
if (sizes == null || sizes.size() <= 0) {
return this;
}
Size bestSize = null;
int diff = Integer.MAX_VALUE;
for (Size tmpSize : sizes) {
int newDiff = Math.abs(tmpSize.width - viewWidth) + Math.abs(tmpSize.height - viewHeight);
if (newDiff == 0) {
bestSize = tmpSize;
break;
} else if (newDiff < diff) {
bestSize = tmpSize;
diff = newDiff;
}
}
params.setPreviewSize(bestSize.width, bestSize.height);
camera.setParameters(params);
return this;
}
示例3: getMaxSupportedVideoSize
import android.hardware.Camera.Size; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private Size getMaxSupportedVideoSize(Camera camera) {
List<Camera.Size> sizes;
if (camera.getParameters().getSupportedVideoSizes() != null) {
sizes = camera.getParameters().getSupportedVideoSizes();
} else {
// Video sizes may be null, which indicates that all the supported
// preview sizes are supported for video recording.
sizes = camera.getParameters().getSupportedPreviewSizes();
}
int maxWidth = sizes.get(0).width;
int maxHeight = sizes.get(0).height;
for (Camera.Size size : sizes) {
if (size.height > maxWidth && size.width > maxHeight) {
maxWidth = size.width;
maxHeight = size.height;
}
}
return new Size(maxWidth, maxHeight);
}
示例4: getPropPreviewSize
import android.hardware.Camera.Size; //导入依赖的package包/类
public Size getPropPreviewSize(List<Size> list, float th, int minWidth){
Collections.sort(list, sizeComparator);
int i = 0;
for(Size s:list){
if((s.width >= minWidth) && equalRate(s, th)){
Log.i(TAG, "PreviewSize:w = " + s.width + "h = " + s.height);
break;
}
i++;
}
if(i == list.size()){
i = 0;//���û�ҵ�����ѡ��С��size
}
return list.get(i);
}
示例5: getPropPictureSize
import android.hardware.Camera.Size; //导入依赖的package包/类
public Size getPropPictureSize(List<Size> list, float th, int minWidth){
Collections.sort(list, sizeComparator);
int i = 0;
for(Size s:list){
if((s.width >= minWidth) && equalRate(s, th)){
Log.i(TAG, "PictureSize : w = " + s.width + "h = " + s.height);
break;
}
i++;
}
if(i == list.size()){
i = 0;//���û�ҵ�����ѡ��С��size
}
return list.get(i);
}
示例6: setPreviewCallback
import android.hardware.Camera.Size; //导入依赖的package包/类
/** 设置回调 */
protected void setPreviewCallback() {
Size size = mParameters.getPreviewSize();
if (size != null) {
PixelFormat pf = new PixelFormat();
PixelFormat.getPixelFormatInfo(mParameters.getPreviewFormat(), pf);
int buffSize = size.width * size.height * pf.bitsPerPixel / 8;
try {
camera.addCallbackBuffer(new byte[buffSize]);
camera.addCallbackBuffer(new byte[buffSize]);
camera.addCallbackBuffer(new byte[buffSize]);
camera.setPreviewCallbackWithBuffer(this);
} catch (OutOfMemoryError e) {
Log.e("Yixia", "startPreview...setPreviewCallback...", e);
}
Log.e("Yixia", "startPreview...setPreviewCallbackWithBuffer...width:" + size.width + " height:" + size.height);
} else {
camera.setPreviewCallback(this);
}
}
示例7: loadTexture
import android.hardware.Camera.Size; //导入依赖的package包/类
public static int loadTexture(final IntBuffer data, final Size size, final int usedTexId) {
int textures[] = new int[1];
if (usedTexId == NO_TEXTURE) {
GLES20.glGenTextures(1, textures, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, size.width, size.height,
0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data);
} else {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, size.width,
size.height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, data);
textures[0] = usedTexId;
}
return textures[0];
}
示例8: getCroppedRect
import android.hardware.Camera.Size; //导入依赖的package包/类
private Rect getCroppedRect(Size cameraPreviewSize, Rect visibleRect, int rotation) {
final int previewWidth = cameraPreviewSize.width;
final int previewHeight = cameraPreviewSize.height;
if (rotation % 180 > 0) rotateRect(visibleRect);
float scale = (float) previewWidth / visibleRect.width();
if (visibleRect.height() * scale > previewHeight) {
scale = (float) previewHeight / visibleRect.height();
}
final float newWidth = visibleRect.width() * scale;
final float newHeight = visibleRect.height() * scale;
final float centerX = (VERSION.SDK_INT < 14 || isTroublemaker()) ? previewWidth - newWidth / 2 : previewWidth / 2;
final float centerY = previewHeight / 2;
visibleRect.set((int) (centerX - newWidth / 2),
(int) (centerY - newHeight / 2),
(int) (centerX + newWidth / 2),
(int) (centerY + newHeight / 2));
if (rotation % 180 > 0) rotateRect(visibleRect);
return visibleRect;
}
示例9: setUpCamera
import android.hardware.Camera.Size; //导入依赖的package包/类
private void setUpCamera(){
mGLSurfaceView.queueEvent(new Runnable() {
@Override
public void run() {
if(mTextureId == OpenGLUtils.NO_TEXTURE){
mTextureId = OpenGLUtils.getExternalOESTextureID();
mSurfaceTexture = new SurfaceTexture(mTextureId);
mSurfaceTexture.setOnFrameAvailableListener(mOnFrameAvailableListener);
}
Size size = CameraEngine.getPreviewSize();
int orientation = CameraEngine.getOrientation();
if(orientation == 90 || orientation == 270){
mImageWidth = size.height;
mImageHeight = size.width;
}else{
mImageWidth = size.width;
mImageHeight = size.height;
}
mCameraInputFilter.onOutputSizeChanged(mImageWidth, mImageHeight);
CameraEngine.startPreview(mSurfaceTexture);
}
});
}
示例10: onPreviewFrame
import android.hardware.Camera.Size; //导入依赖的package包/类
@Override
public void onPreviewFrame(final byte[] data, final Camera camera) {
log.d("onPreviewFrame");
final Size previewSize = camera.getParameters().getPreviewSize();
if (mGLRgbBuffer == null) {
mGLRgbBuffer = IntBuffer.allocate(previewSize.width * previewSize.height);
}
if (mRunOnDraw.isEmpty()) {
runOnDraw(new Runnable() {
@Override
public void run() {
YuvDecoder.YUVtoRBGA(data, previewSize.width, previewSize.height, mGLRgbBuffer.array());
mGLTextureId = OpenGlUtils.loadTexture(mGLRgbBuffer, previewSize, mGLTextureId);
camera.addCallbackBuffer(data);
if (mImageWidth != previewSize.width) {
mImageWidth = previewSize.width;
mImageHeight = previewSize.height;
adjustImageScaling();
}
}
});
}
}
示例11: getPreviewSize
import android.hardware.Camera.Size; //导入依赖的package包/类
public Size getPreviewSize(List<Camera.Size> list, int width,float th){
Collections.sort(list, sizeComparator);
float rate = 1.77f;
if (Math.abs(th-1.33f)<Math.abs(th-1.77f)){
rate = 1.33f;
}else{
rate = 1.77f;
}
int i = 0;
for(Size s:list){
if((s.height > width) && equalRate(s, rate)){
Log.i(TAG, "最终设置预览尺寸:w = " + s.width + "h = " + s.height+","+rate);
break;
}
i++;
}
return list.get(i);
}
示例12: onPreviewFrame
import android.hardware.Camera.Size; //导入依赖的package包/类
@Override
public void onPreviewFrame(final byte[] data, final Camera camera) {
final Size previewSize = camera.getParameters().getPreviewSize();
if (mGLRgbBuffer == null) {
mGLRgbBuffer = IntBuffer.allocate(previewSize.width * previewSize.height);
}
if (mRunOnDraw.isEmpty()) {
runOnDraw(new Runnable() {
@Override
public void run() {
GPUImageNativeLibrary.YUVtoRBGA(data, previewSize.width, previewSize.height,
mGLRgbBuffer.array());
mGLTextureId = OpenGlUtils.loadTexture(mGLRgbBuffer, previewSize, mGLTextureId);
camera.addCallbackBuffer(data);
if (mImageWidth != previewSize.width) {
mImageWidth = previewSize.width;
mImageHeight = previewSize.height;
adjustImageScaling();
}
}
});
}
}
示例13: setDesiredCameraParameters
import android.hardware.Camera.Size; //导入依赖的package包/类
public void setDesiredCameraParameters(Camera camera, int caremaId) {
Camera.Parameters parameters = camera.getParameters();
parameters.setPreviewFormat(ImageFormat.NV21);
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
setZoom(parameters);
camera.setDisplayOrientation(getDisplayOrientation(caremaId));
// 设置照片尺寸
if (this.pictureSize == null) {
WindowManager manager = (WindowManager) mContext
.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
List<Size> pictureSizes = parameters.getSupportedPictureSizes();
this.setPicutreSize(pictureSizes, display.getWidth(),
display.getHeight());
}
try {
parameters.setPictureSize(this.pictureSize.width,
this.pictureSize.height);
} catch (Exception e) {
e.printStackTrace();
}
camera.setParameters(parameters);
}
示例14: determineClosestSupportedResolution
import android.hardware.Camera.Size; //导入依赖的package包/类
/**
* Checks if the requested resolution is supported by the camera.
* If not, it modifies it by supported parameters.
**/
public static VideoQuality determineClosestSupportedResolution(Camera.Parameters parameters, VideoQuality quality) {
VideoQuality v = quality.clone();
int minDist = Integer.MAX_VALUE;
String supportedSizesStr = "Supported resolutions: ";
List<Size> supportedSizes = parameters.getSupportedPreviewSizes();
for (Iterator<Size> it = supportedSizes.iterator(); it.hasNext();) {
Size size = it.next();
supportedSizesStr += size.width+"x"+size.height+(it.hasNext()?", ":"");
int dist = Math.abs(quality.resX - size.width);
if (dist<minDist) {
minDist = dist;
v.resX = size.width;
v.resY = size.height;
}
}
Log.v(TAG, supportedSizesStr);
if (quality.resX != v.resX || quality.resY != v.resY) {
Log.v(TAG,"Resolution modified: "+quality.resX+"x"+quality.resY+"->"+v.resX+"x"+v.resY);
}
return v;
}
示例15: getSupportedVideoSizes
import android.hardware.Camera.Size; //导入依赖的package包/类
@TargetApi(VERSION_CODES.HONEYCOMB)
protected List<Size> getSupportedVideoSizes(int currentSdkInt) {
Parameters params = mNativeCamera.getNativeCameraParameters();
List<Size> supportedVideoSizes;
if (currentSdkInt < Build.VERSION_CODES.HONEYCOMB) {
CLog.e(CLog.CAMERA, "Using supportedPreviewSizes iso supportedVideoSizes due to API restriction");
supportedVideoSizes = params.getSupportedPreviewSizes();
} else if (params.getSupportedVideoSizes() == null) {
CLog.e(CLog.CAMERA, "Using supportedPreviewSizes because supportedVideoSizes is null");
supportedVideoSizes = params.getSupportedPreviewSizes();
} else {
supportedVideoSizes = params.getSupportedVideoSizes();
}
return supportedVideoSizes;
}