当前位置: 首页>>代码示例>>Java>>正文


Java Allocation.copyTo方法代码示例

本文整理汇总了Java中android.support.v8.renderscript.Allocation.copyTo方法的典型用法代码示例。如果您正苦于以下问题:Java Allocation.copyTo方法的具体用法?Java Allocation.copyTo怎么用?Java Allocation.copyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v8.renderscript.Allocation的用法示例。


在下文中一共展示了Allocation.copyTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: yuvToRgb

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:silvaren,项目名称:easyrs,代码行数:29,代码来源:YuvToRgb.java

示例2: getExpectedBitmap

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
@NonNull
private Bitmap getExpectedBitmap(RenderScript rs, Bitmap bmpFromNv21) {
    Allocation ain = Allocation.createFromBitmap(rs, bmpFromNv21);
    Allocation aout = Allocation.createTyped(rs, ain.getType());

    ScriptIntrinsicLUT lutScript = ScriptIntrinsicLUT.create(rs, ain.getElement());
    for (int i = 0; i < LutParams.LUT_SIZE; i++) {
        LutParams.RGBALut rgbaLut = SampleParams.Lut.negative();
        lutScript.setAlpha(i, rgbaLut.aLut[i]);
        lutScript.setRed(i, rgbaLut.rLut[i]);
        lutScript.setGreen(i, rgbaLut.gLut[i]);
        lutScript.setBlue(i, rgbaLut.bLut[i]);
    }
    lutScript.forEach(ain, aout);

    Bitmap expectedBitmap = Bitmap.createBitmap(bmpFromNv21.getWidth(), bmpFromNv21.getHeight(), bmpFromNv21.getConfig());
    aout.copyTo(expectedBitmap);
    return expectedBitmap;
}
 
开发者ID:silvaren,项目名称:easyrs,代码行数:20,代码来源:LutTest.java

示例3: apply

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
public static Bitmap apply(Context context, Bitmap sentBitmap, int radius) {
    final Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
    final RenderScript rs = RenderScript.create(context);
    final Allocation input = Allocation.createFromBitmap(rs, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
    final Allocation output = Allocation.createTyped(rs, input.getType());
    final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));

    script.setRadius(radius);
    script.setInput(input);
    script.forEach(output);
    output.copyTo(bitmap);

    sentBitmap.recycle();
    rs.destroy();
    input.destroy();
    output.destroy();
    script.destroy();

    return bitmap;
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:21,代码来源:Blur.java

示例4: run

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
@Override
public Bitmap run(Bitmap in, BrightnessParams params)
{
	this.params = params;
	
	Bitmap out = Bitmap.createBitmap(in.getWidth(), in.getHeight(), Bitmap.Config.ARGB_8888);
	
	Allocation allocationIn = Allocation.createFromBitmap(renderScript, in);
	Allocation allocationOut = Allocation.createFromBitmap(renderScript, out);
	
	ScriptC_cm_brightness script = new ScriptC_cm_brightness(renderScript);
	attachSelection(script);
	script.set_brightness(params.getBrightness());
	script.set_contrast(params.getContrast());
	script.forEach_invert(allocationIn, allocationOut);
	allocationOut.copyTo(out);
	
	return out;
}
 
开发者ID:karol-202,项目名称:PaintPlusPlus,代码行数:20,代码来源:ColorsBrightness.java

示例5: blur

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
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;
}
 
开发者ID:hanks-zyh,项目名称:FlyWoo,代码行数:20,代码来源:BlurBuilder.java

示例6: transform

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
@Override
public Bitmap transform(Bitmap source) {
    try {
        final RenderScript rs = RenderScript.create(context);
        final Allocation input = Allocation.createFromBitmap(rs, source, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
        final Allocation output = Allocation.createTyped(rs, input.getType());
        final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        script.setRadius(14.f);
        script.setInput(input);
        script.forEach(output);
        output.copyTo(source);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return source;
}
 
开发者ID:gabriellmgomes,项目名称:akhyou,代码行数:17,代码来源:BlurTransform.java

示例7: renderScriptBlur

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
/**
 * Blurs a bitmap using RenderScript (source : http://trickyandroid.com/advanced-blurring-techniques/,
 *  https://plus.google.com/+MarioViviani/posts/fhuzYkji9zz)
 * @param originalBitmap Original bitmap to be blurred (not altered)
 * @param radius Blur amount
 * @return Blurred bitmap
 */
public static Bitmap renderScriptBlur(Bitmap originalBitmap, float radius) {
	Bitmap outBitmap = Bitmap.createBitmap(originalBitmap.getWidth(), originalBitmap.getHeight(),
			Bitmap.Config.ARGB_8888);

	RenderScript rs = Foofy.getInstance().getRenderScriptContext();
	ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
	Allocation allIn = Allocation.createFromBitmap(rs, originalBitmap);
	Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);
	blurScript.setRadius(radius > 25 ? 25 : radius);
	blurScript.setInput(allIn);
	blurScript.forEach(allOut);
	allOut.copyTo(outBitmap);

	//rs.destroy();

	if (radius > 25)
		return renderScriptBlur(outBitmap, radius-25);
	else
		return outBitmap;
}
 
开发者ID:chteuchteu,项目名称:Blurify,代码行数:28,代码来源:BlurUtil.java

示例8: transform

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
@Override
public Bitmap transform(Bitmap bitmap) {
    // Create another bitmap that will hold the results of the filter.
    Bitmap blurredBitmap = bitmap.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);

    bitmap.recycle();

    return blurredBitmap;
}
 
开发者ID:fs-opensource,项目名称:android-tutorials-picasso,代码行数:27,代码来源:BlurTransformation.java

示例9: blur

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
@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;
}
 
开发者ID:allegro,项目名称:fogger,代码行数:24,代码来源:RenderscriptBlurringMachine.java

示例10: blurImageWithRs

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
public static Bitmap blurImageWithRs(Context context, Bitmap input, int radius) {
  RenderScript renderScript = RenderScript.create(context);
  Allocation allocation = Allocation.createFromBitmap(renderScript, input);

  ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript));
  blur.setRadius(radius);
  blur.setInput(allocation);

  Bitmap result = Bitmap.createBitmap(input.getWidth(), input.getHeight(), input.getConfig());
  Allocation outAlloc = Allocation.createFromBitmap(renderScript, result);
  blur.forEach(outAlloc);
  outAlloc.copyTo(result);

  renderScript.destroy();
  return result;
}
 
开发者ID:wingjay,项目名称:jayAndroid,代码行数:17,代码来源:BlurImageHelper.java

示例11: transform

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
@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;
}
 
开发者ID:fs-opensource,项目名称:android-tutorials-glide,代码行数:26,代码来源:BlurTransformation.java

示例12: supportedBlur

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
private Bitmap supportedBlur(Bitmap sentBitmap, int radius)
{
    Bitmap output = Bitmap.createBitmap(sentBitmap.getWidth(), sentBitmap.getHeight(), sentBitmap.getConfig());
    RenderScript rs = RenderScript.create(ApplicationLoader.mainContext);
    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    Allocation inAlloc = Allocation.createFromBitmap(rs, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE);
    Allocation outAlloc = Allocation.createFromBitmap(rs, output);
    script.setRadius(radius > 25 ? 25 : radius);
    script.setInput(inAlloc);
    script.forEach(outAlloc);
    outAlloc.copyTo(output);
    rs.destroy();
    sentBitmap.recycle();
    System.gc();
    return output;
}
 
开发者ID:SelfD3veloper,项目名称:TravelApplication,代码行数:17,代码来源:BlurService.java

示例13: blur

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
public static Bitmap blur(Context ctx, Bitmap image, float radius) {
    int width = Math.round(image.getWidth());
    int height = Math.round(image.getHeight());

    Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
    Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

    RenderScript rs = RenderScript.create(ctx);
    ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
    Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
    theIntrinsic.setRadius(radius);
    theIntrinsic.setInput(tmpIn);
    theIntrinsic.forEach(tmpOut);
    tmpOut.copyTo(outputBitmap);

    return outputBitmap;
}
 
开发者ID:eugenkiss,项目名称:chanobol,代码行数:19,代码来源:Util.java

示例14: transform

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
@Override
public Bitmap transform(Bitmap bitmap) {
	// Create another bitmap that will hold the results of the filter.
	Bitmap blurredBitmap = Bitmap.createBitmap(bitmap);

	// Allocate memory for Renderscript to work with
	Allocation input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_FULL, Allocation.USAGE_SCRIPT);
	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(RADIUS);

	// Start the ScriptIntrinisicBlur
	script.forEach(output);

	// Copy the output to the blurred bitmap
	output.copyTo(blurredBitmap);

	return blurredBitmap;
}
 
开发者ID:lgvalle,项目名称:Beautiful-Photos,代码行数:25,代码来源:BlurTransformation.java

示例15: manipulate

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
@Override
public Bitmap manipulate(Bitmap bitmapOriginal) {
    if (brightness != 0) {
        try {
            Allocation input = Allocation.createFromBitmap(rs, bitmapOriginal);
            final Allocation output = Allocation.createTyped(rs, input.getType());
            ScriptC_brightness mScript = new ScriptC_brightness(rs);
            mScript.invoke_setBright(brightness);
            mScript.forEach_brightness(input, output);
            output.copyTo(bitmapOriginal);
        } catch (RSRuntimeException e) {
            //fallback
        }
    }
    return bitmapOriginal;
}
 
开发者ID:patrickfav,项目名称:Dali,代码行数:17,代码来源:RenderscriptBrightnessProcessor.java


注:本文中的android.support.v8.renderscript.Allocation.copyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。