本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}