android.support.v8.renderscript.Allocation Java Examples
The following examples show how to use
android.support.v8.renderscript.Allocation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Histogram.java From easyrs with MIT License | 6 votes |
/** * Computes a RGBA histogram of a Bitmap. * @return a 1024-length int array of integer frequencies at each channel intensity in the * following interleaved format [R0,G0,B0,A0,R1,G1,B1,A1...] */ public static int[] rgbaHistograms(RenderScript rs, Bitmap inputBitmap) { RSToolboxContext bitmapRSContext = RSToolboxContext.createFromBitmap(rs, inputBitmap); Allocation aout = Allocation.createSized(bitmapRSContext.rs, Element.I32_4(bitmapRSContext.rs), COLOR_DEPTH); ScriptIntrinsicHistogram histogramScript = ScriptIntrinsicHistogram.create( bitmapRSContext.rs, bitmapRSContext.ain.getElement()); histogramScript.setOutput(aout); histogramScript.forEach(bitmapRSContext.ain); int[] histograms = new int[CHANNELS * COLOR_DEPTH]; aout.copyTo(histograms); // RGBA interleaved: [R0,G0,B0,A0,R1,G1,B1,A1... return histograms; }
Example #2
Source File: BlurTransformation.java From android-tutorials-glide with MIT License | 6 votes |
@Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { Bitmap blurredBitmap = toTransform.copy(Bitmap.Config.ARGB_8888, true); // Allocate memory for Renderscript to work with Allocation input = Allocation.createFromBitmap(rs, blurredBitmap, Allocation.MipmapControl.MIPMAP_FULL, Allocation.USAGE_SHARED); Allocation output = Allocation.createTyped(rs, input.getType()); // Load up an instance of the specific script that we want to use. ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setInput(input); // Set the blur radius script.setRadius(10); // Start the ScriptIntrinisicBlur script.forEach(output); // Copy the output to the blurred bitmap output.copyTo(blurredBitmap); toTransform.recycle(); return blurredBitmap; }
Example #3
Source File: Convolution2D.java From style-transfer with Apache License 2.0 | 6 votes |
public void loadModel(String path) throws IOException { mInputStream = mContext.getAssets().open(path + "/W", AssetManager.ACCESS_BUFFER); ByteBuffer bb = readInput(mInputStream); FloatBuffer.wrap(W).put(bb.asFloatBuffer()); // padding for GPU BLAS when necessary. int W_height_input = in_channels * ksize * ksize; if (padded_Y_blas == W_height_input) { // If the input width already satisfies the requirement, just copy to the Allocation. W_alloc.copyFrom(W); } else { // If not, a temp allocation needs to be created. Allocation input = Allocation.createTyped(mRS, Type.createXY(mRS, Element.F32(mRS), W_height_input, out_channels)); input.copyFrom(W); W_alloc.copy2DRangeFrom(0, 0, W_height_input, out_channels, input, 0, 0); } mInputStream = mContext.getAssets().open(path + "/b", AssetManager.ACCESS_BUFFER); bb = readInput(mInputStream); FloatBuffer.wrap(b).put(bb.asFloatBuffer()); b_alloc.copyFrom(b); mInputStream.close(); Log.v(TAG, "Convolution2D loaded: " + b[0]); }
Example #4
Source File: RenderscriptBlurringMachine.java From fogger with Apache License 2.0 | 6 votes |
@Override protected Bitmap blur(Context context, Bitmap bitmapToBlur, int radius) { Log.i(TAG, "Current build version sdk " + Build.VERSION.SDK_INT); Bitmap bitmap = bitmapToBlur.copy(bitmapToBlur.getConfig(), true); final RenderScript renderScript = RenderScript.create(context, Build.VERSION.SDK_INT); final Allocation input = Allocation.createFromBitmap(renderScript, bitmapToBlur, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); final Allocation output = Allocation.createTyped(renderScript, input.getType()); try { final ScriptIntrinsicBlur script = createBlurringScript(radius, renderScript, input); script.forEach(output); renderScript.finish(); output.copyTo(bitmap); } finally { input.destroy(); output.destroy(); bitmapToBlur.recycle(); renderScript.destroy(); } return bitmap; }
Example #5
Source File: BlurBuilder.java From FlyWoo with Apache License 2.0 | 6 votes |
public static Bitmap blur(Context context, Bitmap image) { int width = Math.round(image.getWidth() * BITMAP_SCALE); int height = Math.round(image.getHeight() * BITMAP_SCALE); Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false); Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap); RenderScript rs = RenderScript.create(context); ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap); Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap); theIntrinsic.setRadius(BLUR_RADIUS); theIntrinsic.setInput(tmpIn); theIntrinsic.forEach(tmpOut); tmpOut.copyTo(outputBitmap); return outputBitmap; }
Example #6
Source File: Convolution2DTiled.java From style-transfer with Apache License 2.0 | 6 votes |
public void loadModel(String path) throws IOException { mInputStream = mContext.getAssets().open(path + "/W", AssetManager.ACCESS_BUFFER); ByteBuffer bb = readInput(mInputStream); FloatBuffer.wrap(W).put(bb.asFloatBuffer()); // padding for GPU BLAS when necessary. int W_height_input = in_channels * ksize * ksize; if (padded_Y_blas == W_height_input) { // If the input width already satisfies the requirement, just copy to the Allocation. W_alloc.copyFrom(W); } else { // If not, a temp allocation needs to be created. Allocation input = Allocation.createTyped(mRS, Type.createXY(mRS, Element.F32(mRS), W_height_input, out_channels)); input.copyFrom(W); W_alloc.copy2DRangeFrom(0, 0, W_height_input, out_channels, input, 0, 0); } mInputStream = mContext.getAssets().open(path + "/b", AssetManager.ACCESS_BUFFER); bb = readInput(mInputStream); FloatBuffer.wrap(b).put(bb.asFloatBuffer()); b_alloc.copyFrom(b); mInputStream.close(); Log.v(TAG, "Convolution2D loaded: " + b[0]); }
Example #7
Source File: BlurBuilder.java From react-native-simple-shadow-view with MIT License | 6 votes |
public static Bitmap blur(Context context, Bitmap image, float blurRadius, float scale) { int width = Math.round(image.getWidth() * scale); int height = Math.round(image.getHeight() * scale); Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false); Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap); RenderScript rs = RenderScript.create(context); ScriptIntrinsicBlur intrinsicBlur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap); Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap); intrinsicBlur.setRadius(blurRadius); intrinsicBlur.setInput(tmpIn); intrinsicBlur.forEach(tmpOut); tmpOut.copyTo(outputBitmap); return outputBitmap; }
Example #8
Source File: MainActivity.java From renderscript-samples with Apache License 2.0 | 6 votes |
private void createScript() { mRS = RenderScript.create(this); mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn); mOutAllocations = new Allocation[NUM_BITMAPS]; for (int i = 0; i < NUM_BITMAPS; ++i) { mOutAllocations[i] = Allocation.createFromBitmap(mRS, mBitmapsOut[i]); } // Create intrinsics. // RenderScript has built-in features such as blur, convolve filter etc. // These intrinsics are handy for specific operations without writing RenderScript kernel. // In the sample, it's creating blur, convolve and matrix intrinsics. mScriptBlur = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS)); mScriptConvolve = ScriptIntrinsicConvolve5x5.create(mRS, Element.U8_4(mRS)); mScriptMatrix = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS)); }
Example #9
Source File: ResidualBlock.java From style-transfer with Apache License 2.0 | 6 votes |
public Allocation process(Allocation input, int height, int width) { // 1st convolution. Allocation output = c1.process(input, height, width); // 1st batch normalization. b1.process(output); // Use RELU for the activation function. mActivation.forEach_relu(output, output); // 2nd convolution. output = c2.process(output, c1.outH, c1.outW); // 2nd batch normalization. b2.process(output); // Add the residual back to the input image. mResidualBlock.set_img_alloc(input); mResidualBlock.forEach_add(output, output); // Update the output dimensions. outH = c2.outH; outW = c2.outW; return output; }
Example #10
Source File: RSBox3x3Blur.java From BlurView with Apache License 2.0 | 6 votes |
@Override public Bitmap blur(int radius, Bitmap bitmapOriginal) { radius = Math.min(radius,25); Allocation input = Allocation.createFromBitmap(rs, bitmapOriginal); final Allocation output = Allocation.createTyped(rs, input.getType()); final ScriptIntrinsicConvolve3x3 script = ScriptIntrinsicConvolve3x3.create(rs, Element.U8_4(rs)); script.setCoefficients(BlurKernels.BOX_3x3); for (int i = 0; i < radius; i++) { script.setInput(input); script.forEach(output); input = output; } output.copyTo(bitmapOriginal); return bitmapOriginal; }
Example #11
Source File: BatchNormalization.java From style-transfer with Apache License 2.0 | 6 votes |
public BatchNormalization(Context ctx, RenderScript rs, int size) { super(ctx, rs); this.size = size; gamma = new float[size]; beta = new float[size]; avg_mean = new float[size]; avg_var = new float[size]; // Create RS Allocations. gamma_alloc = Allocation.createSized(mRS, Element.F32(mRS), size); beta_alloc = Allocation.createSized(mRS, Element.F32(mRS), size); avg_mean_alloc = Allocation.createSized(mRS, Element.F32(mRS), size); avg_var_alloc = Allocation.createSized(mRS, Element.F32(mRS), size); // Initialize the BatchNormalization kernel; rs_BN = new ScriptC_batchnormalization(mRS); // Set the global variables for the RS kernel. rs_BN.set_beta_alloc(beta_alloc); rs_BN.set_gamma_alloc(gamma_alloc); rs_BN.set_mean_alloc(avg_mean_alloc); rs_BN.set_var_alloc(avg_var_alloc); rs_BN.set_size(size); }
Example #12
Source File: RSBox5x5Blur.java From BlurView with Apache License 2.0 | 6 votes |
@Override public Bitmap blur(int radius, Bitmap bitmapOriginal) { radius = Math.min(radius,25); Allocation input = Allocation.createFromBitmap(rs, bitmapOriginal); final Allocation output = Allocation.createTyped(rs, input.getType()); final ScriptIntrinsicConvolve5x5 script = ScriptIntrinsicConvolve5x5.create(rs, Element.U8_4(rs)); script.setCoefficients(BlurKernels.BOX_5x5); for (int i = 0; i < radius; i++) { script.setInput(input); script.forEach(output); input = output; } output.copyTo(bitmapOriginal); return bitmapOriginal; }
Example #13
Source File: ResidualBlockTiled.java From style-transfer with Apache License 2.0 | 6 votes |
public Allocation process(Allocation input, int height, int width) { // 1st convolution. Allocation output = c1.process(input, height, width); // 1st batch normalization. b1.process(output); // Use RELU for the activation function. mActivation.forEach_relu(output, output); // 2nd convolution. output = c2.process(output, c1.outH, c1.outW); // 2nd batch normalization. b2.process(output); // Add the residual back to the input image. mResidualBlock.set_img_alloc(input); mResidualBlock.forEach_add(output, output); // Update the output dimensions. outH = c2.outH; outW = c2.outW; return output; }
Example #14
Source File: GBlurPic.java From AndroidGaussianBlur with MIT License | 6 votes |
public Bitmap gBlurBitmap(Bitmap bitmap, float radius) { if (mBitmap != null) { mBitmap.recycle(); mBitmap = null; } mBitmap = bitmap.copy(bitmap.getConfig(), true); mInAllocation = null; mOutAllocation = null; mInAllocation = Allocation.createFromBitmap(mRS, mBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); mOutAllocation = Allocation.createTyped(mRS, mInAllocation.getType()); mBlur.setRadius(radius); mBlur.setInput(mInAllocation); mBlur.forEach(mOutAllocation); mOutAllocation.copyTo(mBitmap); return mBitmap; }
Example #15
Source File: Blur.java From GifImageView with MIT License | 6 votes |
public Bitmap blur(Bitmap image) { if (image == null) return null; image = RGB565toARGB888(image); if (!configured) { input = Allocation.createFromBitmap(rs, image); output = Allocation.createTyped(rs, input.getType()); script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(BLUR_RADIUS); configured = true; } else input.copyFrom(image); script.setInput(input); script.forEach(output); output.copyTo(image); return image; }
Example #16
Source File: HistogramTest.java From easyrs with MIT License | 6 votes |
@NonNull private int[] getExpectedHistogram(RenderScript rs, Bitmap bmpFromNv21, Op op) { Allocation ain = Allocation.createFromBitmap(rs, bmpFromNv21); Allocation aout; int[] histogram; if (op == Op.LUMINANCE) { aout = Allocation.createSized(rs, Element.I32(rs), Histogram.COLOR_DEPTH); histogram = new int[Histogram.COLOR_DEPTH]; } else { aout = Allocation.createSized(rs, Element.I32_4(rs), Histogram.COLOR_DEPTH); histogram = new int[Histogram.COLOR_DEPTH * Histogram.CHANNELS]; } ScriptIntrinsicHistogram histogramScript = ScriptIntrinsicHistogram.create( rs, ain.getElement()); histogramScript.setOutput(aout); histogramScript.forEach(ain); aout.copyTo(histogram); return histogram; }
Example #17
Source File: YuvToRgb.java From easyrs with MIT License | 6 votes |
/** * Converts a NV21 image to a Bitmap. * @param nv21Image the NV21 image to convert. */ public static Bitmap yuvToRgb(RenderScript rs, Nv21Image nv21Image) { long startTime = System.currentTimeMillis(); Type.Builder yuvTypeBuilder = new Type.Builder(rs, Element.U8(rs)) .setX(nv21Image.nv21ByteArray.length); Type yuvType = yuvTypeBuilder.create(); Allocation yuvAllocation = Allocation.createTyped(rs, yuvType, Allocation.USAGE_SCRIPT); yuvAllocation.copyFrom(nv21Image.nv21ByteArray); Type.Builder rgbTypeBuilder = new Type.Builder(rs, Element.RGBA_8888(rs)); rgbTypeBuilder.setX(nv21Image.width); rgbTypeBuilder.setY(nv21Image.height); Allocation rgbAllocation = Allocation.createTyped(rs, rgbTypeBuilder.create()); ScriptIntrinsicYuvToRGB yuvToRgbScript = ScriptIntrinsicYuvToRGB.create(rs, Element.RGBA_8888(rs)); yuvToRgbScript.setInput(yuvAllocation); yuvToRgbScript.forEach(rgbAllocation); Bitmap bitmap = Bitmap.createBitmap(nv21Image.width, nv21Image.height, Bitmap.Config.ARGB_8888); rgbAllocation.copyTo(bitmap); Log.d("NV21", "Conversion to Bitmap: " + (System.currentTimeMillis() - startTime) + "ms"); return bitmap; }
Example #18
Source File: Resize.java From easyrs with MIT License | 6 votes |
/** * Resizes a Bitmap image to a target width and height. */ public static Bitmap resize(RenderScript rs, Bitmap inputBitmap, int targetWidth, int targetHeight) { RSToolboxContext bitmapRSContext = RSToolboxContext.createFromBitmap(rs, inputBitmap); Bitmap.Config config = inputBitmap.getConfig(); Bitmap outputBitmap = Bitmap.createBitmap(targetWidth, targetHeight, config); Type outType = Type.createXY(bitmapRSContext.rs, bitmapRSContext.ain.getElement(), targetWidth, targetHeight); Allocation aout = Allocation.createTyped(bitmapRSContext.rs, outType); ScriptIntrinsicResize resizeScript = ScriptIntrinsicResize.create(bitmapRSContext.rs); resizeScript.setInput(bitmapRSContext.ain); resizeScript.forEach_bicubic(aout); aout.copyTo(outputBitmap); return outputBitmap; }
Example #19
Source File: Histogram.java From easyrs with MIT License | 6 votes |
/** * Computes a luminance histogram of a Bitmap. * @return a 256-length int array of integer frequencies at luminance level. */ public static int[] luminanceHistogram(RenderScript rs, Bitmap inputBitmap) { RSToolboxContext bitmapRSContext = RSToolboxContext.createFromBitmap(rs, inputBitmap); Allocation aout = Allocation.createSized(bitmapRSContext.rs, Element.I32(bitmapRSContext.rs), COLOR_DEPTH); ScriptIntrinsicHistogram histogramScript = ScriptIntrinsicHistogram.create( bitmapRSContext.rs, bitmapRSContext.ain.getElement()); histogramScript.setOutput(aout); histogramScript.forEach(bitmapRSContext.ain); int[] histogram = new int[COLOR_DEPTH]; aout.copyTo(histogram); return histogram; }
Example #20
Source File: Convolve.java From easyrs with MIT License | 5 votes |
@Override public void runConvolveScript(RSToolboxContext rsToolboxContext, Allocation aout, ConvolveParams scriptParams) { ScriptIntrinsicConvolve5x5 convolve5x5Script = ScriptIntrinsicConvolve5x5.create( rsToolboxContext.rs, rsToolboxContext.ain.getElement()); convolve5x5Script.setInput(rsToolboxContext.ain); convolve5x5Script.setCoefficients(scriptParams.coefficients); convolve5x5Script.forEach(aout); }
Example #21
Source File: BitmapUtils.java From Rocko-Android-Demos with Apache License 2.0 | 5 votes |
public static Bitmap blurBitmap(Context applicationContext, Bitmap bitmap, float radius) { //Let's create an empty bitmap with the same size of the bitmap we want to blur Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); //Instantiate a new Renderscript RenderScript rs = RenderScript.create(applicationContext); //Create an Intrinsic Blur Script using the Renderscript ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); //Create the Allocations (in/out) with the Renderscript and the in/out bitmaps Allocation allIn = Allocation.createFromBitmap(rs, bitmap); Allocation allOut = Allocation.createFromBitmap(rs, outBitmap); //Set the radius of the blur blurScript.setRadius(radius); //Perform the Renderscript blurScript.setInput(allIn); blurScript.forEach(allOut); //Copy the final bitmap created by the out Allocation to the outBitmap allOut.copyTo(outBitmap); //recycle the original bitmap bitmap.recycle(); //After finishing everything, we destroy the Renderscript. rs.destroy(); return outBitmap; }
Example #22
Source File: Convolve.java From easyrs with MIT License | 5 votes |
@Override public void runConvolveScript(RSToolboxContext rsToolboxContext, Allocation aout, ConvolveParams scriptParams) { ScriptIntrinsicConvolve3x3 convolve3x3Script = ScriptIntrinsicConvolve3x3.create( rsToolboxContext.rs, rsToolboxContext.ain.getElement()); convolve3x3Script.setInput(rsToolboxContext.ain); convolve3x3Script.setCoefficients(scriptParams.coefficients); convolve3x3Script.forEach(aout); }
Example #23
Source File: ResizeTest.java From easyrs with MIT License | 5 votes |
@NonNull private Bitmap getExpectedBitmap(RenderScript rs, Bitmap bmpFromNv21) { Allocation ain = Allocation.createFromBitmap(rs, bmpFromNv21); Bitmap expectedBitmap = Bitmap.createBitmap(TARGET_WIDTH, TARGET_HEIGHT, bmpFromNv21.getConfig()); Type outType = Type.createXY(rs, ain.getElement(), TARGET_WIDTH, TARGET_HEIGHT); Allocation aout = Allocation.createTyped(rs, outType); ScriptIntrinsicResize resizeScript = ScriptIntrinsicResize.create(rs); resizeScript.setInput(ain); resizeScript.forEach_bicubic(aout); aout.copyTo(expectedBitmap); return expectedBitmap; }
Example #24
Source File: RSBlurProcess.java From BlurView with Apache License 2.0 | 5 votes |
@Override public Bitmap blur(Bitmap original, float radius) { int width = original.getWidth(); int height = original.getHeight(); Bitmap blurred = original.copy(Bitmap.Config.ARGB_8888, true); ScriptC_blur blurScript = new ScriptC_blur(_rs, context.getResources(), R.raw.blur); Allocation inAllocation = Allocation.createFromBitmap(_rs, blurred, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); blurScript.set_gIn(inAllocation); blurScript.set_width(width); blurScript.set_height(height); blurScript.set_radius((int) radius); int[] row_indices = new int[height]; for (int i = 0; i < height; i++) { row_indices[i] = i; } Allocation rows = Allocation.createSized(_rs, Element.U32(_rs), height, Allocation.USAGE_SCRIPT); rows.copyFrom(row_indices); row_indices = new int[width]; for (int i = 0; i < width; i++) { row_indices[i] = i; } Allocation columns = Allocation.createSized(_rs, Element.U32(_rs), width, Allocation.USAGE_SCRIPT); columns.copyFrom(row_indices); blurScript.forEach_blur_h(rows); blurScript.forEach_blur_v(columns); inAllocation.copyTo(blurred); return blurred; }
Example #25
Source File: Convolve.java From easyrs with MIT License | 5 votes |
private static ConvertingTool.BaseToolScript convolveToolScript(final ConvolveScript convolveScript) { return new ConvertingTool.BaseToolScript<ConvolveParams>() { @Override public void runScript(RSToolboxContext rsToolboxrs, Allocation aout, ConvolveParams scriptParams) { convolveScript.runConvolveScript(rsToolboxrs, aout, scriptParams); } }; }
Example #26
Source File: BlurTransformation.java From Sky31Radio with Apache License 2.0 | 5 votes |
@Override public Bitmap transform(Bitmap source) { Timber.i("start bitmap transform"); try { float radius = 10f; Bitmap outputBitmap; // if(Build.VERSION.SDK_INT >= 17){ outputBitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); RenderScript rs = RenderScript.create(ctx); ScriptIntrinsicBlur sib = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); Allocation tmpIn = Allocation.createFromBitmap(rs, source); Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap); sib.setRadius(radius); sib.setInput(tmpIn); sib.forEach(tmpOut); tmpOut.copyTo(outputBitmap); source.recycle(); // }else{ // outputBitmap = FastBlur.doBlur(source, (int) radius, true); // } Timber.d("blur bitmap success"); return outputBitmap; } catch (Exception e) { Timber.e(e, "occur an error during blurring bitmap"); return source; } }
Example #27
Source File: BlurTest.java From easyrs with MIT License | 5 votes |
@NonNull private Bitmap getExpectedBitmap(RenderScript rs, Bitmap bmpFromNv21) { Allocation ain = Allocation.createFromBitmap(rs, bmpFromNv21); Allocation aout = Allocation.createTyped(rs, ain.getType()); ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create( rs, ain.getElement()); blurScript.setInput(ain); blurScript.setRadius(RADIUS); blurScript.forEach(aout); Bitmap expectedBitmap = Bitmap.createBitmap(bmpFromNv21.getWidth(), bmpFromNv21.getHeight(), bmpFromNv21.getConfig()); aout.copyTo(expectedBitmap); return expectedBitmap; }
Example #28
Source File: Lut3DTest.java From easyrs with MIT License | 5 votes |
@NonNull private Bitmap getExpectedBitmap(RenderScript rs, Bitmap bmpFromNv21) { Allocation ain = Allocation.createFromBitmap(rs, bmpFromNv21); Allocation aout = Allocation.createTyped(rs, ain.getType()); ScriptIntrinsic3DLUT script3dLut = ScriptIntrinsic3DLUT.create(rs, ain.getElement()); script3dLut.setLUT(SampleParams.Lut3D.swapRedAndBlueCube().createAllocation(rs)); script3dLut.forEach(ain, aout); Bitmap expectedBitmap = Bitmap.createBitmap(bmpFromNv21.getWidth(), bmpFromNv21.getHeight(), bmpFromNv21.getConfig()); aout.copyTo(expectedBitmap); return expectedBitmap; }
Example #29
Source File: ConvolveTest.java From easyrs with MIT License | 5 votes |
@NonNull private Bitmap getExpectedBitmap5x5(RenderScript rs, Bitmap bmpFromNv21) { Allocation ain = Allocation.createFromBitmap(rs, bmpFromNv21); Allocation aout = Allocation.createTyped(rs, ain.getType()); ScriptIntrinsicConvolve5x5 convolve5x5Script = ScriptIntrinsicConvolve5x5.create(rs, ain.getElement()); convolve5x5Script.setInput(ain); convolve5x5Script.setCoefficients(SampleParams.Convolve.Kernels5x5.SOBEL_X); convolve5x5Script.forEach(aout); Bitmap expectedBitmap = Bitmap.createBitmap(bmpFromNv21.getWidth(), bmpFromNv21.getHeight(), bmpFromNv21.getConfig()); aout.copyTo(expectedBitmap); return expectedBitmap; }
Example #30
Source File: BlendTest.java From easyrs with MIT License | 5 votes |
@NonNull private Bitmap getExpectedBitmap(RenderScript rs, Bitmap bmpFromNv21, Bitmap bmpToAdd) { Allocation ain = Allocation.createFromBitmap(rs, bmpFromNv21); Allocation aout = Allocation.createFromBitmap(rs, bmpToAdd); ScriptIntrinsicBlend blendScript = ScriptIntrinsicBlend.create(rs, ain.getElement()); blendScript.forEachAdd(ain, aout); Bitmap expectedBitmap = Bitmap.createBitmap(bmpFromNv21.getWidth(), bmpFromNv21.getHeight(), bmpFromNv21.getConfig()); aout.copyTo(expectedBitmap); return expectedBitmap; }