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


Java RenderScript.create方法代码示例

本文整理汇总了Java中android.renderscript.RenderScript.create方法的典型用法代码示例。如果您正苦于以下问题:Java RenderScript.create方法的具体用法?Java RenderScript.create怎么用?Java RenderScript.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.renderscript.RenderScript的用法示例。


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

示例1: blur

import android.renderscript.RenderScript; //导入方法依赖的package包/类
private static Bitmap blur(Context context, Bitmap image) {

        int width = Math.round(image.getWidth() * BITMAP_SCALE);
        int height = Math.round(image.getHeight() * BITMAP_SCALE);

        Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

        RenderScript rs = RenderScript.create(context);
        ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
        Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
        theIntrinsic.setRadius(BLUR_RADIUS);
        theIntrinsic.setInput(tmpIn);
        theIntrinsic.forEach(tmpOut);
        tmpOut.copyTo(outputBitmap);

        return outputBitmap;
    }
 
开发者ID:AkshayPall,项目名称:Songify,代码行数:20,代码来源:BlurBackground.java

示例2: blurBitmap

import android.renderscript.RenderScript; //导入方法依赖的package包/类
public static Bitmap blurBitmap(Context context, Bitmap bmp, float radius) {
    Bitmap out = Bitmap.createBitmap(bmp);
    RenderScript rs = RenderScript.create(context);
    radius = Math.min(Math.max(radius, 0), 25);

    Allocation input = Allocation.createFromBitmap(
            rs, bmp, MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
    Allocation output = Allocation.createTyped(rs, input.getType());

    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    script.setInput(input);
    script.setRadius(radius);
    script.forEach(output);

    output.copyTo(out);

    rs.destroy();
    return out;
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:20,代码来源:Utils.java

示例3: blur

import android.renderscript.RenderScript; //导入方法依赖的package包/类
public static Bitmap blur(Context context, Bitmap sentBitmap, int radius) {

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            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); //0.0f ~ 25.0f
            script.setInput(input);
            script.forEach(output);
            output.copyTo(bitmap);
            return bitmap;
        } else {
            return sentBitmap;
        }
    }
 
开发者ID:icaynia,项目名称:pracler,代码行数:20,代码来源:ImageUtils.java

示例4: blur

import android.renderscript.RenderScript; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap blur(UQI uqi, Bitmap image) {
    int width = Math.round(image.getWidth() * BITMAP_SCALE);
    int height = Math.round(image.getHeight() * BITMAP_SCALE);

    Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
    Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

    RenderScript rs = RenderScript.create(uqi.getContext());
    ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
    Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
    theIntrinsic.setRadius(BLUR_RADIUS);
    theIntrinsic.setInput(tmpIn);
    theIntrinsic.forEach(tmpOut);
    tmpOut.copyTo(outputBitmap);

    return outputBitmap;
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:20,代码来源:ImageUtils.java

示例5: renderScriptBlur

import android.renderscript.RenderScript; //导入方法依赖的package包/类
/**
 * renderScript模糊图片
 * <p>API大于17</p>
 *
 * @param src    源图片
 * @param radius 模糊半径(0...25)
 * @return 模糊后的图片
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(final Bitmap src,
                                      @FloatRange(from = 0, to = 25, fromInclusive = false) final float radius) {
    if (isEmptyBitmap(src)) return null;
    RenderScript rs = null;
    try {
        rs = RenderScript.create(Utils.getContext());
        rs.setMessageHandler(new RenderScript.RSMessageHandler());
        Allocation input = Allocation.createFromBitmap(rs, src, Allocation.MipmapControl.MIPMAP_NONE, Allocation
                .USAGE_SCRIPT);
        Allocation output = Allocation.createTyped(rs, input.getType());
        ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        blurScript.setInput(input);
        blurScript.setRadius(radius);
        blurScript.forEach(output);
        output.copyTo(src);
    } finally {
        if (rs != null) {
            rs.destroy();
        }
    }
    return src;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:32,代码来源:ImageUtils.java

示例6: five

import android.renderscript.RenderScript; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap five(Context context, Bitmap bitmap){
    renderScript=RenderScript.create(context);
    outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
    inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
    outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
    final  ScriptIntrinsicColorMatrix colorMatrix5 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
    colorMatrix5.setColorMatrix(new android.renderscript.Matrix4f(new float[]
            {
                    -0.359705309629158f, 0.377252728606377f, 0.663841667303255f, 0f,
                    1.56680818833214f, 0.456668209492391f, 1.12613917506705f, 0f,
                    -0.147102878702981f, 0.226079061901232f, -0.729980842370303f, 0f,
                    0f, 0f, 0f, 1f
            }));
    colorMatrix5.forEach(inputAllocation, outputAllocation);
    outputAllocation.copyTo(outBitmap);
    return outBitmap;
}
 
开发者ID:hgayan7,项目名称:FilterLibrary,代码行数:19,代码来源:PhotoFilter.java

示例7: blur

import android.renderscript.RenderScript; //导入方法依赖的package包/类
public Bitmap blur(Bitmap image) {
    if (null == image) return null;

    Bitmap outputBitmap = Bitmap.createBitmap(image);
    final RenderScript renderScript = RenderScript.create(this);
    Allocation tmpIn = Allocation.createFromBitmap(renderScript, image);
    Allocation tmpOut = Allocation.createFromBitmap(renderScript, outputBitmap);

    //Intrinsic Gausian blur filter
    ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript));
    theIntrinsic.setRadius(BLUR_RADIUS);
    theIntrinsic.setInput(tmpIn);
    theIntrinsic.forEach(tmpOut);
    tmpOut.copyTo(outputBitmap);
    return outputBitmap;
}
 
开发者ID:mdnafiskhan,项目名称:Mp3Player,代码行数:17,代码来源:MusicPlayerActivity.java

示例8: createBlurredImageFromBitmap

import android.renderscript.RenderScript; //导入方法依赖的package包/类
public static Drawable createBlurredImageFromBitmap(Bitmap bitmap, Context context, int inSampleSize) {

        RenderScript rs = RenderScript.create(context);
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = inSampleSize;

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
        byte[] imageInByte = stream.toByteArray();
        ByteArrayInputStream bis = new ByteArrayInputStream(imageInByte);
        Bitmap blurTemplate = BitmapFactory.decodeStream(bis, null, options);

        final Allocation input = Allocation.createFromBitmap(rs, blurTemplate);
        final Allocation output = Allocation.createTyped(rs, input.getType());
        final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        script.setRadius(8f);
        script.setInput(input);
        script.forEach(output);
        output.copyTo(blurTemplate);

        return new BitmapDrawable(context.getResources(), blurTemplate);
    }
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:23,代码来源:ImageLoader.java

示例9: renderScriptBlur

import android.renderscript.RenderScript; //导入方法依赖的package包/类
/**
 * renderScript模糊图片
 * <p>API大于17</p>
 *
 * @param src     源图片
 * @param radius  模糊半径(0...25)
 * @param recycle 是否回收
 * @return 模糊后的图片
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(final Bitmap src, final float radius, final boolean recycle) {
	if (isEmptyBitmap(src)) {
		return null;
	}
	RenderScript rs = null;
	Bitmap ret = recycle ? src : src.copy(src.getConfig(), true);
	try {
		rs = RenderScript.create(Utils.getApp());
		rs.setMessageHandler(new RenderScript.RSMessageHandler());
		Allocation input = Allocation.createFromBitmap(rs, ret, Allocation.MipmapControl.MIPMAP_NONE, Allocation
				.USAGE_SCRIPT);
		Allocation output = Allocation.createTyped(rs, input.getType());
		ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
		blurScript.setInput(input);
		blurScript.setRadius(radius);
		blurScript.forEach(output);
		output.copyTo(ret);
	} finally {
		if (rs != null) {
			rs.destroy();
		}
	}
	return ret;
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:35,代码来源:ImageUtils.java

示例10: renderScriptBlur

import android.renderscript.RenderScript; //导入方法依赖的package包/类
/**
 * renderScript模糊图片
 * <p>API大于17</p>
 *
 * @param src    源图片
 * @param radius 模糊半径(0...25)
 * @return 模糊后的图片
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(Bitmap src, @FloatRange(from = 0, to = 25, fromInclusive = false) float radius) {
    if (isEmptyBitmap(src)) return null;
    RenderScript rs = null;
    try {
        rs = RenderScript.create(Utils.getContext());
        rs.setMessageHandler(new RenderScript.RSMessageHandler());
        Allocation input = Allocation.createFromBitmap(rs, src, Allocation.MipmapControl.MIPMAP_NONE, Allocation
                .USAGE_SCRIPT);
        Allocation output = Allocation.createTyped(rs, input.getType());
        ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        blurScript.setInput(input);
        blurScript.setRadius(radius);
        blurScript.forEach(output);
        output.copyTo(src);
    } finally {
        if (rs != null) {
            rs.destroy();
        }
    }
    return src;
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:31,代码来源:ImageUtils.java

示例11: eight

import android.renderscript.RenderScript; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap eight(Context context, Bitmap bitmap){
    renderScript=RenderScript.create(context);
    outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
    inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
    outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
    final  ScriptIntrinsicColorMatrix colorMatrix8 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
    colorMatrix8.setColorMatrix(new android.renderscript.Matrix4f(new float[]
            {
                    1.44f, 0f, 0f, 0f,
                    0f, 1.44f, 0f, 0f,
                    0f, 0f, 1.44f, 0f,
                    0f, 0f, 0f, 1f,


            }));
    colorMatrix8.forEach(inputAllocation, outputAllocation);
    outputAllocation.copyTo(outBitmap);
    return outBitmap;
}
 
开发者ID:hgayan7,项目名称:FilterLibrary,代码行数:21,代码来源:PhotoFilter.java

示例12: eleven

import android.renderscript.RenderScript; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap eleven(Context context, Bitmap bitmap){
    renderScript=RenderScript.create(context);
    outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
    inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
    outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
    final   ScriptIntrinsicColorMatrix colorMatrix11 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
    colorMatrix11.setColorMatrix(new android.renderscript.Matrix4f(new float[]
            {
                    1.72814708519562f, -0.412104992562475f, 0.541145007437525f, 0f,
                    0.289378264402959f, 1.18835534216106f, -1.17637173559704f, 0f,
                    -1.01752534959858f, 0.223749650401417f, 1.63522672815952f, 0f,
                    0f, 0f, 0f, 1f


            }));
    colorMatrix11.forEach(inputAllocation, outputAllocation);
    outputAllocation.copyTo(outBitmap);
    return outBitmap;
}
 
开发者ID:hgayan7,项目名称:FilterLibrary,代码行数:21,代码来源:PhotoFilter.java

示例13: blur

import android.renderscript.RenderScript; //导入方法依赖的package包/类
public static Bitmap blur(Context context, Bitmap image) {
        int width = Math.round(image.getWidth() * BITMAP_SCALE);
        int height = Math.round(image.getHeight() * BITMAP_SCALE);

        Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

        RenderScript rs = RenderScript.create(context);
        ScriptIntrinsicBlur theIntrinsic = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
            theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
            Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
        Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
        theIntrinsic.setRadius(BLUR_RADIUS);
        theIntrinsic.setInput(tmpIn);
        theIntrinsic.forEach(tmpOut);
        tmpOut.copyTo(outputBitmap);
        }else{
            outputBitmap= BlurHelper.doBlur(image,(int)BLUR_RADIUS,false);
        }


        return outputBitmap;

}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:26,代码来源:TabsFragmentOne.java

示例14: blurBitmap

import android.renderscript.RenderScript; //导入方法依赖的package包/类
public static Bitmap blurBitmap(Context context, Bitmap bitmap) {
    if (context == null || bitmap == null) return null;

    Bitmap blurredBitmap;
    try {
        blurredBitmap = Bitmap.createBitmap(bitmap);
    } catch (OutOfMemoryError e) {
        return null;
    }

    RenderScript renderScript = RenderScript.create(context);
    Allocation input = Allocation.createFromBitmap(renderScript, bitmap, Allocation.MipmapControl.MIPMAP_FULL, Allocation.USAGE_SCRIPT);
    Allocation output = Allocation.createTyped(renderScript, input.getType());
    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript));

    script.setInput(input);
    script.setRadius(20);

    script.forEach(output);
    output.copyTo(blurredBitmap);

    return blurredBitmap;
}
 
开发者ID:TheAndroidMaster,项目名称:Pasta-for-Spotify,代码行数:24,代码来源:ImageUtils.java

示例15: blurBitmap

import android.renderscript.RenderScript; //导入方法依赖的package包/类
@Nullable
public static Bitmap blurBitmap(Context context, Bitmap bitmap) {
    if (context == null || bitmap == null) return null;

    Bitmap blurredBitmap;
    try {
        blurredBitmap = Bitmap.createBitmap(bitmap);
    } catch (OutOfMemoryError e) {
        return null;
    }

    RenderScript renderScript = RenderScript.create(context);
    Allocation input = Allocation.createFromBitmap(renderScript, bitmap, Allocation.MipmapControl.MIPMAP_FULL, Allocation.USAGE_SCRIPT);
    Allocation output = Allocation.createTyped(renderScript, input.getType());
    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript));

    script.setInput(input);
    script.setRadius(20);

    script.forEach(output);
    output.copyTo(blurredBitmap);

    return blurredBitmap;
}
 
开发者ID:TheAndroidMaster,项目名称:Bagels,代码行数:25,代码来源:ImageUtils.java


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