use of android.hardware.Camera.Size in project MagicCamera by wuhaoyu1990.
the class CameraEngine method getLargePictureSize.
private static Size getLargePictureSize() {
if (mCamera != null) {
List<Size> sizes = mCamera.getParameters().getSupportedPictureSizes();
Size temp = sizes.get(0);
for (int i = 1; i < sizes.size(); i++) {
float scale = (float) (sizes.get(i).height) / sizes.get(i).width;
if (temp.width < sizes.get(i).width && scale < 0.6f && scale > 0.5f)
temp = sizes.get(i);
}
return temp;
}
return null;
}
use of android.hardware.Camera.Size in project MagicCamera by wuhaoyu1990.
the class CameraEngine method getLargePreviewSize.
private static Size getLargePreviewSize() {
if (mCamera != null) {
List<Size> sizes = mCamera.getParameters().getSupportedPreviewSizes();
Size temp = sizes.get(0);
for (int i = 1; i < sizes.size(); i++) {
if (temp.width < sizes.get(i).width)
temp = sizes.get(i);
}
return temp;
}
return null;
}
use of android.hardware.Camera.Size in project QRCode by 5peak2me.
the class DecodeHandler method decode.
/**
* Decode the data within the viewfinder rectangle, and time how long it
* took. For efficiency, reuse the same reader objects from one decode to
* the next.
*
* @param data
* The YUV preview frame.
* @param width
* The width of the preview frame.
* @param height
* The height of the preview frame.
*/
private void decode(byte[] data, int width, int height) {
Size size = activity.getCameraManager().getPreviewSize();
// 这里需要将获取的data翻转一下,因为相机默认拿的的横屏的数据
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < size.height; y++) {
for (int x = 0; x < size.width; x++) rotatedData[x * size.height + size.height - y - 1] = data[x + y * size.width];
}
// 宽高也要调整
int tmp = size.width;
size.width = size.height;
size.height = tmp;
Result rawResult = null;
PlanarYUVLuminanceSource source = buildLuminanceSource(rotatedData, size.width, size.height);
if (source != null) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
}
Handler handler = activity.getHandler();
if (rawResult != null) {
// Don't log the barcode contents for security.
if (handler != null) {
Message message = Message.obtain(handler, R.id.decode_succeeded, rawResult);
Bundle bundle = new Bundle();
bundleThumbnail(source, bundle);
message.setData(bundle);
message.sendToTarget();
}
} else {
if (handler != null) {
Message message = Message.obtain(handler, R.id.decode_failed);
message.sendToTarget();
}
}
}
use of android.hardware.Camera.Size in project android_packages_apps_Camera by CyanogenMod.
the class VideoModule method storeImage.
private void storeImage(final byte[] data, Location loc) {
long dateTaken = System.currentTimeMillis();
String title = Util.createJpegName(dateTaken);
int orientation = Exif.getOrientation(data);
Size s = mParameters.getPictureSize();
Uri uri = Storage.getStorage().addImage(mContentResolver, title, dateTaken, loc, orientation, data, s.width, s.height);
if (uri != null) {
Util.broadcastNewPicture(mActivity, uri);
}
}
use of android.hardware.Camera.Size in project android_packages_apps_Camera by CyanogenMod.
the class PhotoModule method setPreviewFrameLayoutAspectRatio.
void setPreviewFrameLayoutAspectRatio() {
// Set the preview frame aspect ratio according to the picture size.
Size size = mParameters.getPictureSize();
mPreviewFrameLayout.setAspectRatio((double) size.width / size.height);
}
Aggregations