本文整理了Java中android.renderscript.Allocation.destroy()
方法的一些代码示例,展示了Allocation.destroy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Allocation.destroy()
方法的具体详情如下:
包路径:android.renderscript.Allocation
类名称:Allocation
方法名:destroy
暂无
代码示例来源:origin: Dimezis/BlurView
@Override
public final void destroy() {
blurScript.destroy();
renderScript.destroy();
if (outAllocation != null) {
outAllocation.destroy();
}
}
代码示例来源:origin: Dimezis/BlurView
/**
* @param bitmap bitmap to blur
* @param blurRadius blur radius (1..25)
* @return blurred bitmap
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public final Bitmap blur(Bitmap bitmap, float blurRadius) {
//Allocation will use the same backing array of pixels as bitmap if created with USAGE_SHARED flag
Allocation inAllocation = Allocation.createFromBitmap(renderScript, bitmap);
if (!canReuseAllocation(bitmap)) {
if (outAllocation != null) {
outAllocation.destroy();
}
outAllocation = Allocation.createTyped(renderScript, inAllocation.getType());
lastBitmapWidth = bitmap.getWidth();
lastBitmapHeight = bitmap.getHeight();
}
blurScript.setRadius(blurRadius);
blurScript.setInput(inAllocation);
//do not use inAllocation in forEach. it will cause visual artifacts on blurred Bitmap
blurScript.forEach(outAllocation);
outAllocation.copyTo(bitmap);
inAllocation.destroy();
return bitmap;
}
代码示例来源:origin: wasabeef/glide-transformations
input.destroy();
output.destroy();
代码示例来源:origin: wasabeef/Blurry
input.destroy();
output.destroy();
代码示例来源:origin: guolindev/giffun
input.destroy();
output.destroy();
代码示例来源:origin: eventtus/photo-editor-android
private void releaseBitmap() {
if (mBlurInput != null) {
mBlurInput.destroy();
mBlurInput = null;
}
if (mBlurOutput != null) {
mBlurOutput.destroy();
mBlurOutput = null;
}
if (mBitmapToBlur != null) {
mBitmapToBlur.recycle();
mBitmapToBlur = null;
}
if (mBlurredBitmap != null) {
mBlurredBitmap.recycle();
mBlurredBitmap = null;
}
}
代码示例来源:origin: BrianValente/WAMOD
@Override
public final void destroy() {
blurScript.destroy();
renderScript.destroy();
if (outAllocation != null) {
outAllocation.destroy();
}
}
代码示例来源:origin: BrianValente/WAMOD
/**
* @param bitmap bitmap to blur
* @param blurRadius blur radius (1..25)
* @return blurred bitmap
*/
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public final Bitmap blur(Bitmap bitmap, float blurRadius) {
//Allocation will use the same backing array of pixels as bitmap if created with USAGE_SHARED flag
Allocation inAllocation = Allocation.createFromBitmap(renderScript, bitmap);
if (!canReuseAllocation(bitmap)) {
if (outAllocation != null) {
outAllocation.destroy();
}
outAllocation = Allocation.createTyped(renderScript, inAllocation.getType());
lastBitmapWidth = bitmap.getWidth();
lastBitmapHeight = bitmap.getHeight();
}
blurScript.setRadius(blurRadius);
blurScript.setInput(inAllocation);
//do not use inAllocation in forEach. it will cause visual artifacts on blurred Bitmap
blurScript.forEach(outAllocation);
outAllocation.copyTo(bitmap);
inAllocation.destroy();
return bitmap;
}
代码示例来源:origin: ImangazalievM/Bubbble
input.destroy();
output.destroy();
代码示例来源: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: 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: chuanqi305/rscnn
out.destroy();
代码示例来源:origin: chuanqi305/rscnn
out.destroy();
代码示例来源:origin: chuanqi305/rscnn
1.f, colAllocation, kernelAllocation, 0.f, outputFeatureMap);
colAllocation.destroy();
内容来源于网络,如有侵权,请联系作者删除!