android.support.v8.renderscript.RSRuntimeException Java Examples
The following examples show how to use
android.support.v8.renderscript.RSRuntimeException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StackBlurManager.java From BlurView with Apache License 2.0 | 6 votes |
/** * Process the image using renderscript if possible * Fall back to native if renderscript is not available * @param context renderscript requires an android context * @param radius */ public Bitmap processRenderScript(Context context, float radius) { BlurProcess blurProcess; // The renderscript support library doesn't have .so files for ARMv6. // Remember if there is an error creating the renderscript context, // and fall back to NativeBlurProcess if(hasRS) { try { blurProcess = new RSBlurProcess(context); } catch (RSRuntimeException e) { if(BuildConfig.DEBUG) { Log.i("StackBlurManager", "Falling back to Native Blur", e); } blurProcess = new NativeBlurProcess(); hasRS = false; } } else { blurProcess = new NativeBlurProcess(); } _result = blurProcess.blur(_image, radius); return _result; }
Example #2
Source File: RenderScriptBlur.java From EtsyBlur with Apache License 2.0 | 6 votes |
public synchronized static boolean isAvailable(@NonNull Context context) { if (!isAvailabilityChecked) { boolean available = true; RenderScript rs = null; try { rs = RenderScript.create(context); } catch (RSRuntimeException e) { Log.w(TAG, "Renderscript is not available on this device."); available = false; } finally { if (rs != null) { rs.destroy(); } isAvailabilityChecked = true; isAvailable = available; } } return isAvailable; }
Example #3
Source File: RenderScriptBlurHelper.java From BlurDialogFragment with Apache License 2.0 | 5 votes |
/** * blur a given bitmap * * @param sentBitmap bitmap to blur * @param radius blur radius * @param canReuseInBitmap true if bitmap must be reused without blur * @param context used by RenderScript, can be null if RenderScript disabled * @return blurred bitmap */ public static Bitmap doBlur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap, Context context) { Bitmap bitmap; if (canReuseInBitmap) { bitmap = sentBitmap; } else { bitmap = sentBitmap.copy(sentBitmap.getConfig(), true); } if (bitmap.getConfig() == Bitmap.Config.RGB_565) { // RenderScript hates RGB_565 so we convert it to ARGB_8888 // (see http://stackoverflow.com/questions/21563299/ // defect-of-image-with-scriptintrinsicblur-from-support-library) bitmap = convertRGB565toARGB888(bitmap); } try { final RenderScript rs = RenderScript.create(context); final Allocation input = Allocation.createFromBitmap(rs, bitmap, 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); return bitmap; } catch (RSRuntimeException e) { Log.e(TAG, "RenderScript known error : https://code.google.com/p/android/issues/detail?id=71347 " + "continue with the FastBlur approach."); } return null; }