public ViewfinderProcessor(RenderScript rs, Size dimensions) { Type.Builder yuvTypeBuilder = new Type.Builder(rs, Element.YUV(rs)); yuvTypeBuilder.SetX(dimensions.Width); yuvTypeBuilder.SetY(dimensions.Height); yuvTypeBuilder.SetYuvFormat((int)ImageFormatType.Yuv420888); mInputHdrAllocation = Allocation.CreateTyped(rs, yuvTypeBuilder.Create(), AllocationUsage.IoInput | AllocationUsage.Script); Type.Builder rgbTypeBuilder = new Type.Builder(rs, Element.RGBA_8888(rs)); rgbTypeBuilder.SetX(dimensions.Width); rgbTypeBuilder.SetY(dimensions.Height); mPrevAllocation = Allocation.CreateTyped(rs, rgbTypeBuilder.Create(), AllocationUsage.Script); mOutputAllocation = Allocation.CreateTyped(rs, rgbTypeBuilder.Create(), AllocationUsage.IoOutput | AllocationUsage.Script); mHdrYuvToRGBScript = ScriptIntrinsicYuvToRGB.Create(rs, Element.RGBA_8888(rs)); mHdrColorMatrixScript = ScriptIntrinsicColorMatrix.Create(rs); mHdrColorMatrixScript.SetColorMatrix(new Matrix4f(new float[] { 0.5f, 0, 0, 0, 0, 0.5f, 0, 0, 0, 0, 0.5f, 0, 0, 0, 0, 0.5f })); mHdrBlendScript = ScriptIntrinsicBlend.Create(rs, Element.RGBA_8888(rs)); mDimensions = dimensions; mFrameCounter = 0; SetRenderMode(ModeNormal); }
protected override void DisposeObject() { if (_input != null) { _input.Destroy(); _input = null; } if (_yuvToRgbIntrinsic != null) { _yuvToRgbIntrinsic.Destroy(); _yuvToRgbIntrinsic = null; } if (rs != null) { rs.Destroy(); rs = null; } }
public YUV420Converter(Context context) { rs = RenderScript.Create(context); _yuvToRgbIntrinsic = ScriptIntrinsicYuvToRGB.Create(rs, Element.U8_4(rs)); }