当前位置: 首页>>代码示例>>Java>>正文


Java RSRuntimeException类代码示例

本文整理汇总了Java中android.support.v8.renderscript.RSRuntimeException的典型用法代码示例。如果您正苦于以下问题:Java RSRuntimeException类的具体用法?Java RSRuntimeException怎么用?Java RSRuntimeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RSRuntimeException类属于android.support.v8.renderscript包,在下文中一共展示了RSRuntimeException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processRenderScript

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:vipulyaara,项目名称:betterHotels,代码行数:29,代码来源:StackBlurManager.java

示例2: processRenderScript

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
/**
 * 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
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
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) {
			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;
}
 
开发者ID:Cangol,项目名称:AndroidStackBlur,代码行数:27,代码来源:StackBlurManager.java

示例3: processRenderScript

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:xiaozhi003,项目名称:BeautyGallery,代码行数:30,代码来源:StackBlurManager.java

示例4: updateToolbarShadow

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
private void updateToolbarShadow() {
    if (Build.VERSION.SDK_INT < 11) return;
    try {
        toolbar.setDrawingCacheEnabled(true);
        toolbar.buildDrawingCache();
        Bitmap bm = toolbar.getDrawingCache();
        if (bm == null) {
            toolbar.setDrawingCacheEnabled(false);
            return;
        }
        if (Build.VERSION.SDK_INT < 12) bm = Util.setHasAlphaCompat(bm);
        else bm.setHasAlpha(true);
        toolbarShadow.setImageBitmap(Util.blur(this, bm, 1f));
        toolbarShadow.setColorFilter(Color.argb(255, 0, 0, 0));
        toolbar.setDrawingCacheEnabled(false);
    } catch (RSRuntimeException ignored) {
        // Simply do not draw a shadow for devices that can't handle it
    }
}
 
开发者ID:eugenkiss,项目名称:chanobol,代码行数:20,代码来源:MediaActivity.java

示例5: isAvailable

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
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;
}
 
开发者ID:Manabu-GT,项目名称:EtsyBlur,代码行数:20,代码来源:RenderScriptBlur.java

示例6: manipulate

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override
public Bitmap manipulate(Bitmap bitmapOriginal) {
    if (brightness != 0) {
        try {
            Allocation input = Allocation.createFromBitmap(rs, bitmapOriginal);
            final Allocation output = Allocation.createTyped(rs, input.getType());
            ScriptC_brightness mScript = new ScriptC_brightness(rs);
            mScript.invoke_setBright(brightness);
            mScript.forEach_brightness(input, output);
            output.copyTo(bitmapOriginal);
        } catch (RSRuntimeException e) {
            //fallback
        }
    }
    return bitmapOriginal;
}
 
开发者ID:patrickfav,项目名称:Dali,代码行数:17,代码来源:RenderscriptBrightnessProcessor.java

示例7: doBlur

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:44,代码来源:BlurRenderScriptHelper.java

示例8: doBlur

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:44,代码来源:RenderScriptBlurHelper.java

示例9: manipulate

import android.support.v8.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override
public Bitmap manipulate(Bitmap bitmapOriginal) {
    try {
        Allocation input = Allocation.createFromBitmap(rs, bitmapOriginal);
        final Allocation output = Allocation.createTyped(rs, input.getType());
        ScriptIntrinsicColorMatrix mScript = ScriptIntrinsicColorMatrix.create(rs, Element.U8(rs));
        Matrix4f matrix4f = new Matrix4f(data);
        mScript.setColorMatrix(matrix4f);
        output.copyTo(bitmapOriginal);
    } catch (RSRuntimeException e) {
        //fallback
    }
    return bitmapOriginal;
}
 
开发者ID:patrickfav,项目名称:Dali,代码行数:15,代码来源:RenderScriptColorFilter.java


注:本文中的android.support.v8.renderscript.RSRuntimeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。