本文整理匯總了Java中android.support.v8.renderscript.RSInvalidStateException類的典型用法代碼示例。如果您正苦於以下問題:Java RSInvalidStateException類的具體用法?Java RSInvalidStateException怎麽用?Java RSInvalidStateException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RSInvalidStateException類屬於android.support.v8.renderscript包,在下文中一共展示了RSInvalidStateException類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: blurBitmap
import android.support.v8.renderscript.RSInvalidStateException; //導入依賴的package包/類
public Bitmap blurBitmap(Bitmap src, float radius, float desaturateAmount) {
if (src == null) {
return null;
}
Bitmap dest = Bitmap.createBitmap(src);
if (radius == 0f && desaturateAmount == 0f) {
return dest;
}
if (mTmp1 != null) {
mTmp1.destroy();
}
if (mTmp2 != null) {
try {
mTmp2.destroy();
} catch (RSInvalidStateException e) {
// Ignore 'Object already destroyed' exceptions
}
}
mTmp1 = Allocation.createFromBitmap(mRS, src);
mTmp2 = Allocation.createFromBitmap(mRS, dest);
if (radius > 0f && desaturateAmount > 0f) {
doBlur(radius, mTmp1, mTmp2);
doDesaturate(MathUtil.constrain(0, 1, desaturateAmount), mTmp2, mTmp1);
mTmp1.copyTo(dest);
} else if (radius > 0f) {
doBlur(radius, mTmp1, mTmp2);
mTmp2.copyTo(dest);
} else {
doDesaturate(MathUtil.constrain(0, 1, desaturateAmount), mTmp1, mTmp2);
mTmp2.copyTo(dest);
}
return dest;
}
示例2: destroyRenderScriptContext
import android.support.v8.renderscript.RSInvalidStateException; //導入依賴的package包/類
public void destroyRenderScriptContext() {
if (renderScriptContext != null) {
try {
renderScriptContext.destroy();
} catch (RSInvalidStateException | NullPointerException ignoredException) {
// Ignored exception
}
}
}