本文整理了Java中android.renderscript.Element
类的一些代码示例,展示了Element
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element
类的具体详情如下:
包路径:android.renderscript.Element
类名称:Element
暂无
代码示例来源:origin: Dimezis/BlurView
/**
* @param context Context to create the {@link RenderScript}
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public RenderScriptBlur(Context context) {
renderScript = RenderScript.create(context);
blurScript = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript));
}
代码示例来源:origin: gearvrf/GearVRf-Demos
Type.Builder yuvTypeBuilder = new Type.Builder(rs, Element.U8_4(rs));
yuvTypeBuilder.setX(width);
yuvTypeBuilder.setY(height);
yuvTypeBuilder.setYuvFormat(ImageFormat.YUV_420_888);
Type.Builder rgbTypeBuilder = new Type.Builder(rs, Element.RGBA_8888(rs));
rgbTypeBuilder.setX(width);
rgbTypeBuilder.setY(height);
Allocation.USAGE_SCRIPT);
mScriptIntrinsic = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs));
} else {
mInputAllocation = Allocation.createTyped(rs, rgbTypeBuilder.create(),
代码示例来源:origin: googlesamples/android-HdrViewfinder
public ViewfinderProcessor(RenderScript rs, Size dimensions) {
Type.Builder yuvTypeBuilder = new Type.Builder(rs, Element.YUV(rs));
yuvTypeBuilder.setX(dimensions.getWidth());
yuvTypeBuilder.setY(dimensions.getHeight());
yuvTypeBuilder.setYuvFormat(ImageFormat.YUV_420_888);
mInputHdrAllocation = Allocation.createTyped(rs, yuvTypeBuilder.create(),
Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
mInputNormalAllocation = Allocation.createTyped(rs, yuvTypeBuilder.create(),
Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
Type.Builder rgbTypeBuilder = new Type.Builder(rs, Element.RGBA_8888(rs));
rgbTypeBuilder.setX(dimensions.getWidth());
rgbTypeBuilder.setY(dimensions.getHeight());
mPrevAllocation = Allocation.createTyped(rs, rgbTypeBuilder.create(),
Allocation.USAGE_SCRIPT);
mOutputAllocation = Allocation.createTyped(rs, rgbTypeBuilder.create(),
Allocation.USAGE_IO_OUTPUT | Allocation.USAGE_SCRIPT);
HandlerThread processingThread = new HandlerThread("ViewfinderProcessor");
processingThread.start();
mProcessingHandler = new Handler(processingThread.getLooper());
mHdrMergeScript = new ScriptC_hdr_merge(rs);
mHdrMergeScript.set_gPrevFrame(mPrevAllocation);
mHdrTask = new ProcessingTask(mInputHdrAllocation, dimensions.getWidth()/2, true);
mNormalTask = new ProcessingTask(mInputNormalAllocation, 0, false);
setRenderMode(MODE_NORMAL);
}
代码示例来源:origin: chuanqi305/rscnn
@Override
public void computeOutputShape() {
outputShape = inputShape[0];
if(softmaxScript!=null){
int n = inputShape[0][0];
int h = inputShape[0][1];
int w = inputShape[0][2];
int c = inputShape[0][3];
Type expSumType = Type.createX(renderScript, Element.F32(renderScript), n * h * w);
expSumAlloc = Allocation.createTyped(renderScript, expSumType, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_SCRIPT);
softmaxScript.set_channel(c);
softmaxScript.set_expSum(expSumAlloc);
}
}
}
代码示例来源:origin: chuanqi305/rscnn
Allocation kernelAllocation;
Allocation biasAllocation;
kernelType = Type.createX(renderScript, Element.F32_4(renderScript), c * inh * inw * inc / 4);
biasType = Type.createX(renderScript, Element.F32(renderScript), c);
代码示例来源:origin: chuanqi305/rscnn
@Override
public void setup(){
int n = inputShape[0][0];
int h = inputShape[0][1];
int w = inputShape[0][2];
int c = inputShape[0][3];
Type expSumType = Type.createX(renderScript, Element.F32(renderScript), n * h * w);
expSumAlloc = Allocation.createTyped(renderScript, expSumType, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_SCRIPT);
softmaxScript = new ScriptC_Softmax(renderScript);
softmaxScript.set_channel(c);
softmaxScript.set_expSum(expSumAlloc);
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
/**
* 图片高斯模糊具体实现方法
*/
public static Bitmap blur(Context context, Bitmap image, float radius) {
// 计算图片缩小后的长宽
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内核对象
RenderScript rs = RenderScript.create(context);
// 创建一个模糊效果的RenderScript的工具对象
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
// 由于RenderScript并没有使用VM来分配内存,所以需要使用Allocation类来创建和分配内存空间。
// 创建Allocation对象的时候其实内存是空的,需要使用copyTo()将数据填充进去。
Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
// 设置渲染的模糊程度, 25f是最大模糊度
blurScript.setRadius(radius);
// 设置blurScript对象的输入内存
blurScript.setInput(tmpIn);
// 将输出数据保存到输出内存中
blurScript.forEach(tmpOut);
// 将数据填充到Allocation中
tmpOut.copyTo(outputBitmap);
return outputBitmap;
}
}
代码示例来源:origin: chuanqi305/rscnn
protected void allocFeatureMapNoPad()
{
Type.Builder outputType = new Type.Builder(renderScript, Element.F32(renderScript));
outputType.setZ(outputShape[0]);
outputType.setY(outputShape[1] * outputShape[2]);
outputType.setX(outputShape[3]);
Allocation outAllocation = Allocation.createTyped(renderScript, outputType.create());
FeatureMap output = new FeatureMap();
output.setFeatureMap(outAllocation);
output.setN(outputShape[0]);
output.setH(outputShape[1]);
output.setW(outputShape[2]);
output.setC(outputShape[3]);
output.setPad4(false);
if(this.featureMapOutput!=null){
((FeatureMap)featureMapOutput).getFeatureMap().destroy();
}
this.featureMapOutput = output;
}
代码示例来源:origin: cymcsg/UltimateAndroid
Allocation.USAGE_SCRIPT);
final Allocation output = Allocation.createTyped(rs, input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
代码示例来源:origin: chuanqi305/rscnn
Allocation biasAllocation;
Type.Builder kernelType = new Type.Builder(renderScript, Element.F32(renderScript));
kernelType.setX(inputChannelAligned);
kernelType.setY(kernelH * kernelW);
Type biasType = Type.createX(renderScript, Element.F32(renderScript), inputChannelAligned);
kernelAllocation = Allocation.createTyped(renderScript, kernelType.create(), Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_SCRIPT);
biasAllocation = Allocation.createTyped(renderScript, biasType, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_SCRIPT);
代码示例来源:origin: CameraKit/blurkit-android
public Bitmap blur(Bitmap src, int radius) {
final Allocation input = Allocation.createFromBitmap(rs, src);
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(src);
return src;
}
代码示例来源:origin: chuanqi305/rscnn
protected void allocFeatureMap()
{
Type.Builder outputType = new Type.Builder(renderScript, Element.F32(renderScript));
outputType.setZ(outputShape[0]);
outputType.setY(outputShape[1] * outputShape[2]);
outputType.setX(getOutputChannelAligned());
Allocation outAllocation = Allocation.createTyped(renderScript, outputType.create());
FeatureMap output = new FeatureMap();
output.setFeatureMap(outAllocation);
output.setN(outputShape[0]);
output.setH(outputShape[1]);
output.setW(outputShape[2]);
output.setC(outputShape[3]);
output.setPad4(true);
if(this.featureMapOutput!=null){
((FeatureMap)featureMapOutput).getFeatureMap().destroy();
}
this.featureMapOutput = output;
}
代码示例来源:origin: wasabeef/glide-transformations
Allocation.USAGE_SCRIPT);
output = Allocation.createTyped(rs, input.getType());
blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
代码示例来源:origin: chuanqi305/rscnn
Type outType = Type.createX(renderScript, Element.F32(renderScript), outNum * outHeight * outWidth * outChannel);
代码示例来源:origin: wasabeef/Blurry
Allocation.USAGE_SCRIPT);
output = Allocation.createTyped(rs, input.getType());
blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
代码示例来源:origin: chuanqi305/rscnn
int outWidth = outputShape[2];
Type.Builder kernelType = new Type.Builder(renderScript, Element.F32(renderScript));
kernelType.setY(outputChannelAligned);
kernelType.setX(kernelH * kernelW * inputChannelGroup);
Type biasType = Type.createX(renderScript, Element.F32(renderScript), outputChannelAligned);
代码示例来源:origin: multidots/android-app-common-tasks
input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs,
Element.U8_4(rs));
代码示例来源:origin: chuanqi305/rscnn
Type.Builder colType = new Type.Builder(renderScript, Element.F32(renderScript));
colType.setX(kernelH * kernelW * inputChannelAligned).setY(outputHeight * outputWidth);
Allocation colAllocation = Allocation.createTyped(renderScript, colType.create());
代码示例来源:origin: multidots/android-app-common-tasks
input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs,
Element.U8_4(rs));
代码示例来源:origin: Blizzard-liu/AndroidUtils
input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs,
Element.U8_4(rs));
内容来源于网络,如有侵权,请联系作者删除!