Search in sources :

Example 1 with Type

use of android.renderscript.Type in project platform_frameworks_base by android.

the class Camera method createPreviewAllocation.

/**
     * <p>Create a {@link android.renderscript RenderScript}
     * {@link android.renderscript.Allocation Allocation} to use as a
     * destination of preview callback frames. Use
     * {@link #setPreviewCallbackAllocation setPreviewCallbackAllocation} to use
     * the created Allocation as a destination for camera preview frames.</p>
     *
     * <p>The Allocation will be created with a YUV type, and its contents must
     * be accessed within Renderscript with the {@code rsGetElementAtYuv_*}
     * accessor methods. Its size will be based on the current
     * {@link Parameters#getPreviewSize preview size} configured for this
     * camera.</p>
     *
     * @param rs the RenderScript context for this Allocation.
     * @param usage additional usage flags to set for the Allocation. The usage
     *   flag {@link android.renderscript.Allocation#USAGE_IO_INPUT} will always
     *   be set on the created Allocation, but additional flags may be provided
     *   here.
     * @return a new YUV-type Allocation with dimensions equal to the current
     *   preview size.
     * @throws RSIllegalArgumentException if the usage flags are not compatible
     *   with an YUV Allocation.
     * @see #setPreviewCallbackAllocation
     * @hide
     */
public final Allocation createPreviewAllocation(RenderScript rs, int usage) throws RSIllegalArgumentException {
    Parameters p = getParameters();
    Size previewSize = p.getPreviewSize();
    Type.Builder yuvBuilder = new Type.Builder(rs, Element.createPixel(rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
    // Use YV12 for wide compatibility. Changing this requires also
    // adjusting camera service's format selection.
    yuvBuilder.setYuvFormat(ImageFormat.YV12);
    yuvBuilder.setX(previewSize.width);
    yuvBuilder.setY(previewSize.height);
    Allocation a = Allocation.createTyped(rs, yuvBuilder.create(), usage | Allocation.USAGE_IO_INPUT);
    return a;
}
Also used : Type(android.renderscript.Type) SdkConstantType(android.annotation.SdkConstant.SdkConstantType) Allocation(android.renderscript.Allocation)

Example 2 with Type

use of android.renderscript.Type in project android_frameworks_base by DirtyUnicorns.

the class Camera method createPreviewAllocation.

/**
     * <p>Create a {@link android.renderscript RenderScript}
     * {@link android.renderscript.Allocation Allocation} to use as a
     * destination of preview callback frames. Use
     * {@link #setPreviewCallbackAllocation setPreviewCallbackAllocation} to use
     * the created Allocation as a destination for camera preview frames.</p>
     *
     * <p>The Allocation will be created with a YUV type, and its contents must
     * be accessed within Renderscript with the {@code rsGetElementAtYuv_*}
     * accessor methods. Its size will be based on the current
     * {@link Parameters#getPreviewSize preview size} configured for this
     * camera.</p>
     *
     * @param rs the RenderScript context for this Allocation.
     * @param usage additional usage flags to set for the Allocation. The usage
     *   flag {@link android.renderscript.Allocation#USAGE_IO_INPUT} will always
     *   be set on the created Allocation, but additional flags may be provided
     *   here.
     * @return a new YUV-type Allocation with dimensions equal to the current
     *   preview size.
     * @throws RSIllegalArgumentException if the usage flags are not compatible
     *   with an YUV Allocation.
     * @see #setPreviewCallbackAllocation
     * @hide
     */
public final Allocation createPreviewAllocation(RenderScript rs, int usage) throws RSIllegalArgumentException {
    Parameters p = getParameters();
    Size previewSize = p.getPreviewSize();
    Type.Builder yuvBuilder = new Type.Builder(rs, Element.createPixel(rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
    // Use YV12 for wide compatibility. Changing this requires also
    // adjusting camera service's format selection.
    yuvBuilder.setYuvFormat(ImageFormat.YV12);
    yuvBuilder.setX(previewSize.width);
    yuvBuilder.setY(previewSize.height);
    Allocation a = Allocation.createTyped(rs, yuvBuilder.create(), usage | Allocation.USAGE_IO_INPUT);
    return a;
}
Also used : Type(android.renderscript.Type) SdkConstantType(android.annotation.SdkConstant.SdkConstantType) Allocation(android.renderscript.Allocation)

Example 3 with Type

use of android.renderscript.Type in project android_frameworks_base by AOSPA.

the class Camera method createPreviewAllocation.

/**
     * <p>Create a {@link android.renderscript RenderScript}
     * {@link android.renderscript.Allocation Allocation} to use as a
     * destination of preview callback frames. Use
     * {@link #setPreviewCallbackAllocation setPreviewCallbackAllocation} to use
     * the created Allocation as a destination for camera preview frames.</p>
     *
     * <p>The Allocation will be created with a YUV type, and its contents must
     * be accessed within Renderscript with the {@code rsGetElementAtYuv_*}
     * accessor methods. Its size will be based on the current
     * {@link Parameters#getPreviewSize preview size} configured for this
     * camera.</p>
     *
     * @param rs the RenderScript context for this Allocation.
     * @param usage additional usage flags to set for the Allocation. The usage
     *   flag {@link android.renderscript.Allocation#USAGE_IO_INPUT} will always
     *   be set on the created Allocation, but additional flags may be provided
     *   here.
     * @return a new YUV-type Allocation with dimensions equal to the current
     *   preview size.
     * @throws RSIllegalArgumentException if the usage flags are not compatible
     *   with an YUV Allocation.
     * @see #setPreviewCallbackAllocation
     * @hide
     */
public final Allocation createPreviewAllocation(RenderScript rs, int usage) throws RSIllegalArgumentException {
    Parameters p = getParameters();
    Size previewSize = p.getPreviewSize();
    Type.Builder yuvBuilder = new Type.Builder(rs, Element.createPixel(rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
    // Use YV12 for wide compatibility. Changing this requires also
    // adjusting camera service's format selection.
    yuvBuilder.setYuvFormat(ImageFormat.YV12);
    yuvBuilder.setX(previewSize.width);
    yuvBuilder.setY(previewSize.height);
    Allocation a = Allocation.createTyped(rs, yuvBuilder.create(), usage | Allocation.USAGE_IO_INPUT);
    return a;
}
Also used : Type(android.renderscript.Type) SdkConstantType(android.annotation.SdkConstant.SdkConstantType) Allocation(android.renderscript.Allocation)

Example 4 with Type

use of android.renderscript.Type in project android_frameworks_base by ResurrectionRemix.

the class Camera method createPreviewAllocation.

/**
     * <p>Create a {@link android.renderscript RenderScript}
     * {@link android.renderscript.Allocation Allocation} to use as a
     * destination of preview callback frames. Use
     * {@link #setPreviewCallbackAllocation setPreviewCallbackAllocation} to use
     * the created Allocation as a destination for camera preview frames.</p>
     *
     * <p>The Allocation will be created with a YUV type, and its contents must
     * be accessed within Renderscript with the {@code rsGetElementAtYuv_*}
     * accessor methods. Its size will be based on the current
     * {@link Parameters#getPreviewSize preview size} configured for this
     * camera.</p>
     *
     * @param rs the RenderScript context for this Allocation.
     * @param usage additional usage flags to set for the Allocation. The usage
     *   flag {@link android.renderscript.Allocation#USAGE_IO_INPUT} will always
     *   be set on the created Allocation, but additional flags may be provided
     *   here.
     * @return a new YUV-type Allocation with dimensions equal to the current
     *   preview size.
     * @throws RSIllegalArgumentException if the usage flags are not compatible
     *   with an YUV Allocation.
     * @see #setPreviewCallbackAllocation
     * @hide
     */
public final Allocation createPreviewAllocation(RenderScript rs, int usage) throws RSIllegalArgumentException {
    Parameters p = getParameters();
    Size previewSize = p.getPreviewSize();
    Type.Builder yuvBuilder = new Type.Builder(rs, Element.createPixel(rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
    // Use YV12 for wide compatibility. Changing this requires also
    // adjusting camera service's format selection.
    yuvBuilder.setYuvFormat(ImageFormat.YV12);
    yuvBuilder.setX(previewSize.width);
    yuvBuilder.setY(previewSize.height);
    Allocation a = Allocation.createTyped(rs, yuvBuilder.create(), usage | Allocation.USAGE_IO_INPUT);
    return a;
}
Also used : Type(android.renderscript.Type) SdkConstantType(android.annotation.SdkConstant.SdkConstantType) Allocation(android.renderscript.Allocation)

Example 5 with Type

use of android.renderscript.Type in project android_frameworks_base by crdroidandroid.

the class Camera method createPreviewAllocation.

/**
     * <p>Create a {@link android.renderscript RenderScript}
     * {@link android.renderscript.Allocation Allocation} to use as a
     * destination of preview callback frames. Use
     * {@link #setPreviewCallbackAllocation setPreviewCallbackAllocation} to use
     * the created Allocation as a destination for camera preview frames.</p>
     *
     * <p>The Allocation will be created with a YUV type, and its contents must
     * be accessed within Renderscript with the {@code rsGetElementAtYuv_*}
     * accessor methods. Its size will be based on the current
     * {@link Parameters#getPreviewSize preview size} configured for this
     * camera.</p>
     *
     * @param rs the RenderScript context for this Allocation.
     * @param usage additional usage flags to set for the Allocation. The usage
     *   flag {@link android.renderscript.Allocation#USAGE_IO_INPUT} will always
     *   be set on the created Allocation, but additional flags may be provided
     *   here.
     * @return a new YUV-type Allocation with dimensions equal to the current
     *   preview size.
     * @throws RSIllegalArgumentException if the usage flags are not compatible
     *   with an YUV Allocation.
     * @see #setPreviewCallbackAllocation
     * @hide
     */
public final Allocation createPreviewAllocation(RenderScript rs, int usage) throws RSIllegalArgumentException {
    Parameters p = getParameters();
    Size previewSize = p.getPreviewSize();
    Type.Builder yuvBuilder = new Type.Builder(rs, Element.createPixel(rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
    // Use YV12 for wide compatibility. Changing this requires also
    // adjusting camera service's format selection.
    yuvBuilder.setYuvFormat(ImageFormat.YV12);
    yuvBuilder.setX(previewSize.width);
    yuvBuilder.setY(previewSize.height);
    Allocation a = Allocation.createTyped(rs, yuvBuilder.create(), usage | Allocation.USAGE_IO_INPUT);
    return a;
}
Also used : Type(android.renderscript.Type) SdkConstantType(android.annotation.SdkConstant.SdkConstantType) Allocation(android.renderscript.Allocation)

Aggregations

SdkConstantType (android.annotation.SdkConstant.SdkConstantType)5 Allocation (android.renderscript.Allocation)5 Type (android.renderscript.Type)5