本文整理了Java中android.support.v8.renderscript.Allocation.destroy()
方法的一些代码示例,展示了Allocation.destroy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Allocation.destroy()
方法的具体详情如下:
包路径:android.support.v8.renderscript.Allocation
类名称:Allocation
方法名:destroy
暂无
代码示例来源:origin: mmin18/RealtimeBlurView
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: 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
*/
@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: SmartDengg/RxBlur
public void destroy() {
mSIBlur.destroy();
if (mTmp1 != null) {
mTmp1.destroy();
}
if (mTmp2 != null) {
mTmp2.destroy();
}
mRS.destroy();
}
}
代码示例来源:origin: Rance935/SectorMenu
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@WorkerThread
private Bitmap getBlurBitmap(Context context, Bitmap inBitmap, float radius) {
if (context == null || inBitmap == null) {
throw new IllegalArgumentException("have not called setParams() before call execute()");
}
int width = Math.round(inBitmap.getWidth() * SCALE);
int height = Math.round(inBitmap.getHeight() * SCALE);
Bitmap in = Bitmap.createScaledBitmap(inBitmap, width, height, false);
Bitmap out = Bitmap.createBitmap(in);
RenderScript rs = RenderScript.create(context);
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation allocationIn = Allocation.createFromBitmap(rs, in);
Allocation allocationOut = Allocation.createFromBitmap(rs, out);
blurScript.setRadius(radius);
blurScript.setInput(allocationIn);
blurScript.forEach(allocationOut);
allocationOut.copyTo(out);
allocationIn.destroy();
allocationOut.destroy();
blurScript.destroy();
rs.destroy();
return out;
}
代码示例来源:origin: dongorigin/AndroidDemo
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;
}
代码示例来源:origin: SmartDengg/RxBlur
mTmp1.destroy();
mTmp2.destroy();
} catch (RSInvalidStateException e) {
内容来源于网络,如有侵权,请联系作者删除!