Search in sources :

Example 21 with Size

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;
}
Also used : Size(android.hardware.Camera.Size)

Example 22 with Size

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;
}
Also used : Size(android.hardware.Camera.Size)

Example 23 with Size

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();
        }
    }
}
Also used : Message(android.os.Message) Size(android.hardware.Camera.Size) PlanarYUVLuminanceSource(com.google.zxing.PlanarYUVLuminanceSource) Bundle(android.os.Bundle) Handler(android.os.Handler) BinaryBitmap(com.google.zxing.BinaryBitmap) HybridBinarizer(com.google.zxing.common.HybridBinarizer) Result(com.google.zxing.Result) ReaderException(com.google.zxing.ReaderException)

Example 24 with Size

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);
    }
}
Also used : Size(android.hardware.Camera.Size) Uri(android.net.Uri)

Example 25 with Size

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);
}
Also used : Size(android.hardware.Camera.Size)

Aggregations

Size (android.hardware.Camera.Size)30 Parameters (android.hardware.Camera.Parameters)4 Point (android.graphics.Point)3 Camera (android.hardware.Camera)3 Uri (android.net.Uri)2 IOException (java.io.IOException)2 TargetApi (android.annotation.TargetApi)1 SharedPreferences (android.content.SharedPreferences)1 Editor (android.content.SharedPreferences.Editor)1 SurfaceTexture (android.graphics.SurfaceTexture)1 Location (android.location.Location)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Message (android.os.Message)1 Nullable (android.support.annotation.Nullable)1 BinaryBitmap (com.google.zxing.BinaryBitmap)1 PlanarYUVLuminanceSource (com.google.zxing.PlanarYUVLuminanceSource)1 ReaderException (com.google.zxing.ReaderException)1 Result (com.google.zxing.Result)1 HybridBinarizer (com.google.zxing.common.HybridBinarizer)1