本文介绍了onPictureTaken byte []在某些设备中较小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Surfaceview创建自定义相机应用程序.在我的应用程序中,我捕获了图片,但它在Note 4中运行良好,在小米手机中有问题,我不知道为什么会发生这种情况.
I Creating custom camera app i am using Surfaceview. In my app i capture the picture but it work perfectly in Note 4 and it problematic in xiaomi mobile and i don't the reason why this happen.
注释4 onPictureTaken Byte []大小是原始的.
但是
小米onPictureTaken字节[]大小始终为160x120
这是我的代码
PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
final BitmapFactory.Options sizeOptions = new BitmapFactory.Options();
// sizeOptions.inJustDecodeBounds = false;
sizeOptions.inScaled = false;
// sizeOptions.inDither = false;
sizeOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
BitmapFactory.decodeByteArray(data, 0, data.length, sizeOptions);
Log.d("onPictureTaken", "Bitmap is " + sizeOptions.outWidth + "x"
+ sizeOptions.outHeight);
int angleToRotate = getRoatationAngle(currentCameraId);
Log.d("Tag", "Rotation angle: " + angleToRotate);
if (currentCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT)
angleToRotate = angleToRotate + 180;
final String albumId = Util.ReadSharePrefrence(getActivity(), Constant.SHRED_PR.KEY_Current_AlbumID);
new SavePhotoTask(albumId, data, angleToRotate, isChecked, orientation).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
camera.startPreview();
}
};
推荐答案
我发布问题大约3个小时,但没有人发表评论.
I am post question for about 3 hours but no one even commenting.
我找出问题所在.这取决于参数部分参考
I figure out whats the problem. It is depending on parameter part Reference
这是我的代码
private void initPreview(int width, int height) {
if (camera != null && previewHolder.getSurface() != null) {
try {
camera.setPreviewDisplay(previewHolder);
} catch (Throwable t) {
// Log.e("PreviewDemo-surfaceCallback","Exception in setPreviewDisplay()");
}
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = getBestPreviewSize(width, height, parameters);
parameters.setJpegQuality(90);
if (size != null) {
Log.d("", "initPreview: width = "+size.width+ " height = "+size.height);
parameters.setPreviewSize(size.width, size.height);
parameters.setPictureSize(size.width, size.height);
camera.setParameters(parameters);
cameraConfigured = true;
}
}
}
这篇关于onPictureTaken byte []在某些设备中较小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!