當前位置: 首頁>>代碼示例>>Java>>正文


Java RenderScript.setMessageHandler方法代碼示例

本文整理匯總了Java中android.renderscript.RenderScript.setMessageHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java RenderScript.setMessageHandler方法的具體用法?Java RenderScript.setMessageHandler怎麽用?Java RenderScript.setMessageHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.renderscript.RenderScript的用法示例。


在下文中一共展示了RenderScript.setMessageHandler方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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,
                                      @FloatRange(from = 0, to = 25, fromInclusive = false) 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:weiwenqiang,項目名稱:GitHub,代碼行數:35,代碼來源:ImageUtils.java

示例2: 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:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:31,代碼來源:ImageUtils.java

示例3: 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

示例4: 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

示例5: renderScriptBlur

import android.renderscript.RenderScript; //導入方法依賴的package包/類
/**
 * renderScript模糊圖片
 * <p>API大於17</p>
 *
 * @param context 上下文
 * @param src 源圖片
 * @param radius 模糊半徑(0...25)
 * @return 模糊後的圖片
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(Context context, Bitmap src, @FloatRange(from = 0, to = 25, fromInclusive = false) float radius) {
    if (isEmptyBitmap(src)) {
        return null;
    }
    RenderScript rs = null;
    try {
        rs = RenderScript.create(context);
        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:imliujun,項目名稱:LJFramework,代碼行數:35,代碼來源:ImageUtils.java

示例6: 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

示例7: 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,
                                      @FloatRange(from = 0, to = 25, fromInclusive = false) 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(SDAndroidLib.getContext());
        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:SiberiaDante,項目名稱:AndroidUtilLib,代碼行數:35,代碼來源:SDBitmapUtil.java

示例8: renderScriptBlur

import android.renderscript.RenderScript; //導入方法依賴的package包/類
/**
 * renderScript模糊圖片
 * <p>API大於17</p>
 *
 * @param context 上下文
 * @param src     源圖片
 * @param radius  模糊度(1...25)
 * @return 模糊後的圖片
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(Context context, Bitmap src, float radius) {
    if (isEmptyBitmap(src)) return null;
    RenderScript rs = null;
    try {
        rs = RenderScript.create(context);
        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));
        if (radius > 25) {
            radius = 25.0f;
        } else if (radius <= 0) {
            radius = 1.0f;
        }
        blurScript.setInput(input);
        blurScript.setRadius(radius);
        blurScript.forEach(output);
        output.copyTo(src);
    } finally {
        if (rs != null) {
            rs.destroy();
        }
    }
    return src;
}
 
開發者ID:tututututututu,項目名稱:BaseCore,代碼行數:37,代碼來源:ImageUtils.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,
                                      @FloatRange(
                                              from = 0, to = 25, fromInclusive = false
                                      ) final float radius,
                                      final boolean recycle) {
    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:Blankj,項目名稱:AndroidUtilCode,代碼行數:38,代碼來源: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, float radius) {
    if (isEmptyBitmap(src)) return null;
    RenderScript rs = null;
    try {
        rs = RenderScript.create(RxTool.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));
        if (radius > 25) {
            radius = 25.0f;
        } else if (radius <= 0) {
            radius = 1.0f;
        }
        blurScript.setInput(input);
        blurScript.setRadius(radius);
        blurScript.forEach(output);
        output.copyTo(src);
    } finally {
        if (rs != null) {
            rs.destroy();
        }
    }
    return src;
}
 
開發者ID:vondear,項目名稱:RxTools,代碼行數:36,代碼來源:RxImageTool.java


注:本文中的android.renderscript.RenderScript.setMessageHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。