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


Java RSRuntimeException类代码示例

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


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

示例1: of

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
public static Bitmap of(Context context, Bitmap source, BlurFactor factor) {
  int width = factor.width / factor.sampling;
  int height = factor.height / factor.sampling;

  if (Helper.hasZero(width, height)) {
    return null;
  }

  Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

  Canvas canvas = new Canvas(bitmap);
  canvas.scale(1 / (float) factor.sampling, 1 / (float) factor.sampling);
  Paint paint = new Paint();
  paint.setFlags(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
  PorterDuffColorFilter filter =
      new PorterDuffColorFilter(factor.color, PorterDuff.Mode.SRC_ATOP);
  paint.setColorFilter(filter);
  canvas.drawBitmap(source, 0, 0, paint);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    try {
      bitmap = Blur.rs(context, bitmap, factor.radius);
    } catch (RSRuntimeException e) {
      bitmap = Blur.stack(bitmap, factor.radius, true);
    }
  } else {
    bitmap = Blur.stack(bitmap, factor.radius, true);
  }

  if (factor.sampling == BlurFactor.DEFAULT_SAMPLING) {
    return bitmap;
  } else {
    Bitmap scaled = Bitmap.createScaledBitmap(bitmap, factor.width, factor.height, true);
    bitmap.recycle();
    return scaled;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:Blur.java

示例2: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
        Bitmap source = resource.get();

        int width = source.getWidth();
        int height = source.getHeight();
        int scaledWidth = width / mSampling;
        int scaledHeight = height / mSampling;

        Bitmap bitmap = mBitmapPool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
        if (bitmap == null) {
                bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
        }

        Canvas canvas = new Canvas(bitmap);
        canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
        Paint paint = new Paint();
        paint.setFlags(Paint.FILTER_BITMAP_FLAG);
        canvas.drawBitmap(source, 0, 0, paint);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                try {
                        bitmap = RSBlur.blur(mContext, bitmap, mRadius);
                } catch (RSRuntimeException e) {
                        bitmap = FastBlur.blur(bitmap, mRadius, true);
                }
        } else {
                bitmap = FastBlur.blur(bitmap, mRadius, true);
        }

        return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:33,代码来源:BlurTransformation.java

示例3: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
    Bitmap source = resource.get();

    int width = source.getWidth();
    int height = source.getHeight();
    int scaledWidth = width / mSampling;
    int scaledHeight = height / mSampling;

    Bitmap bitmap = mBitmapPool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
    if (bitmap == null) {
        bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(bitmap);
    canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(source, 0, 0, paint);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        try {
            bitmap = RSBlur.blur(mContext, bitmap, mRadius);
        } catch (RSRuntimeException e) {
            bitmap = FastBlur.blur(bitmap, mRadius, true);
        }
    } else {
        bitmap = FastBlur.blur(bitmap, mRadius, true);
    }

    return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:33,代码来源:BlurTransformation.java

示例4: start

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
/**
 * @param originalBitmap   原始的bitmap
 * @param radius           模糊的半径
 * @param canReuseInBitmap 是否创建新的bitmap进行处理
 * @return 处理完成的bitmap
 */
public static Bitmap start(Bitmap originalBitmap, int radius, boolean canReuseInBitmap) {
    Bitmap bitmap;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        try {
            bitmap = RSBlur.blur(originalBitmap, radius);
        } catch (RSRuntimeException e) {
            bitmap = FastBlur.blur(originalBitmap, radius, canReuseInBitmap);
        }
    } else {
        bitmap = FastBlur.blur(originalBitmap, radius, canReuseInBitmap);
    }
    return bitmap;
}
 
开发者ID:zhonglikui,项目名称:cardinalsSample,代码行数:20,代码来源:Blur.java

示例5: of

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
public static Bitmap of(Context context, Bitmap source, BlurFactor factor) {
	int width = factor.width / factor.sampling;
	int height = factor.height / factor.sampling;

	if (Helper.hasZero(width, height)) {
		return null;
	}

	Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

	Canvas canvas = new Canvas(bitmap);
	canvas.scale(1 / (float) factor.sampling, 1 / (float) factor.sampling);
	Paint paint = new Paint();
	paint.setFlags(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
	PorterDuffColorFilter filter =
			new PorterDuffColorFilter(factor.color, PorterDuff.Mode.SRC_ATOP);
	paint.setColorFilter(filter);
	canvas.drawBitmap(source, 0, 0, paint);

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
		try {
			bitmap = Blur.rs(context, bitmap, factor.radius);
		} catch (RSRuntimeException e) {
			bitmap = Blur.stack(bitmap, factor.radius, true);
		}
	} else {
		bitmap = Blur.stack(bitmap, factor.radius, true);
	}

	if (factor.sampling == BlurFactor.DEFAULT_SAMPLING) {
		return bitmap;
	} else {
		Bitmap scaled = Bitmap.createScaledBitmap(bitmap, factor.width, factor.height, true);
		bitmap.recycle();
		return scaled;
	}
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:38,代码来源:Blur.java

示例6: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  Bitmap source = resource.get();

  int width = source.getWidth();
  int height = source.getHeight();
  int scaledWidth = width / mSampling;
  int scaledHeight = height / mSampling;

  Bitmap bitmap = mBitmapPool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
  if (bitmap == null) {
    bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
  }

  Canvas canvas = new Canvas(bitmap);
  canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
  Paint paint = new Paint();
  paint.setFlags(Paint.FILTER_BITMAP_FLAG);
  canvas.drawBitmap(source, 0, 0, paint);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    try {
      bitmap = RSBlur.blur(mContext, bitmap, mRadius);
    } catch (RSRuntimeException e) {
      bitmap = FastBlur.blur(bitmap, mRadius, true);
    }
  } else {
    bitmap = FastBlur.blur(bitmap, mRadius, true);
  }

  return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:open-android,项目名称:Glide-transformations,代码行数:33,代码来源:BlurTransformation.java

示例7: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override public Bitmap transform(Bitmap source) {

        int scaledWidth = source.getWidth() / mSampling;
        int scaledHeight = source.getHeight() / mSampling;

        Bitmap bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);

        Canvas canvas = new Canvas(bitmap);
        canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
        Paint paint = new Paint();
        paint.setFlags(Paint.FILTER_BITMAP_FLAG);
        canvas.drawBitmap(source, 0, 0, paint);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            try {
                bitmap = RsBlur.blur(mContext, bitmap, mRadius);
            } catch (RSRuntimeException e) {
                bitmap = FastBlur.blur(bitmap, mRadius, true);
            }
        } else {
            bitmap = FastBlur.blur(bitmap, mRadius, true);
        }

        //source.recycle();

        return bitmap;
    }
 
开发者ID:dmallcott,项目名称:DismissibleImageView,代码行数:28,代码来源:BlurTransformation.java

示例8: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override public Bitmap transform(Bitmap source) {

    int scaledWidth = source.getWidth() / mSampling;
    int scaledHeight = source.getHeight() / mSampling;

    Bitmap bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(source, 0, 0, paint);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      try {
        bitmap = RSBlur.blur(mContext, bitmap, mRadius);
      } catch (RSRuntimeException e) {
        bitmap = FastBlur.blur(bitmap, mRadius, true);
      }
    } else {
      bitmap = FastBlur.blur(bitmap, mRadius, true);
    }

    source.recycle();

    return bitmap;
  }
 
开发者ID:open-android,项目名称:Picasso-transformations,代码行数:28,代码来源:BlurTransformation.java

示例9: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override public Bitmap transform(Bitmap source) {

        int scaledWidth = source.getWidth() / mSampling;
        int scaledHeight = source.getHeight() / mSampling;

        Bitmap bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);

        Canvas canvas = new Canvas(bitmap);
        canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
        Paint paint = new Paint();
        paint.setFlags(Paint.FILTER_BITMAP_FLAG);
        canvas.drawBitmap(source, 0, 0, paint);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            try {
                bitmap = RSBlur.blur(mContext, bitmap, mRadius);
            } catch (RSRuntimeException e) {
                bitmap = FastBlur.blur(bitmap, mRadius, true);
            }
        } else {
            bitmap = FastBlur.blur(bitmap, mRadius, true);
        }

        source.recycle();

        return bitmap;
    }
 
开发者ID:HabeebAhmed1234,项目名称:RecordPlayer,代码行数:28,代码来源:BlurTransformation.java

示例10: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
    @NonNull Bitmap toTransform, int outWidth, int outHeight) {

  int width = toTransform.getWidth();
  int height = toTransform.getHeight();
  int scaledWidth = width / sampling;
  int scaledHeight = height / sampling;

  Bitmap bitmap = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);

  Canvas canvas = new Canvas(bitmap);
  canvas.scale(1 / (float) sampling, 1 / (float) sampling);
  Paint paint = new Paint();
  paint.setFlags(Paint.FILTER_BITMAP_FLAG);
  canvas.drawBitmap(toTransform, 0, 0, paint);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    try {
      bitmap = RSBlur.blur(context, bitmap, radius);
    } catch (RSRuntimeException e) {
      bitmap = FastBlur.blur(bitmap, radius, true);
    }
  } else {
    bitmap = FastBlur.blur(bitmap, radius, true);
  }

  return bitmap;
}
 
开发者ID:wasabeef,项目名称:glide-transformations,代码行数:29,代码来源:BlurTransformation.java

示例11: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override public Bitmap transform(Bitmap source) {

    int scaledWidth = source.getWidth() / mSampling;
    int scaledHeight = source.getHeight() / mSampling;

    Bitmap bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(source, 0, 0, paint);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
      try {
        bitmap = RSBlur.blur(mContext, bitmap, mRadius);
      } catch (RSRuntimeException e) {
        bitmap = FastBlur.blur(bitmap, mRadius, true);
      }
    } else {
      bitmap = FastBlur.blur(bitmap, mRadius, true);
    }

    source.recycle();

    return bitmap;
  }
 
开发者ID:wasabeef,项目名称:picasso-transformations,代码行数:28,代码来源:BlurTransformation.java

示例12: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
    int sampling;
    if (this.sampling == 0) {
        sampling = ImageUtil.calculateInSampleSize(toTransform.getWidth(), toTransform.getHeight(), 100);
    } else {
        sampling = this.sampling;
    }

    int width = toTransform.getWidth();
    int height = toTransform.getHeight();
    int scaledWidth = width / sampling;
    int scaledHeight = height / sampling;

    Bitmap out = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
    if (out == null) {
        out = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(out);
    canvas.scale(1 / (float) sampling, 1 / (float) sampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(toTransform, 0, 0, paint);

    if (Build.VERSION.SDK_INT >= 17) {
        try {
            final RenderScript rs = RenderScript.create(context.getApplicationContext());
            final Allocation input = Allocation.createFromBitmap(rs, out, 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(blurRadius);
            script.setInput(input);
            script.forEach(output);

            output.copyTo(out);

            rs.destroy();

            return out;

        } catch (RSRuntimeException e) {
            // on some devices RenderScript.create() throws: android.support.v8.renderscript.RSRuntimeException: Error loading libRSSupport library
            if (BuildConfig.DEBUG) e.printStackTrace();
        }
    }

    return StackBlur.blur(out, blurRadius);
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:51,代码来源:BlurTransformation.java

示例13: transform

import android.renderscript.RSRuntimeException; //导入依赖的package包/类
@Override
public Resource<Bitmap> transform(Context context, Resource<Bitmap> resource, int outWidth, int outHeight) {
    Bitmap source = resource.get();

    int width = source.getWidth();
    int height = source.getHeight();

    float sampling = mSampling;
    int radius = mRadius;
    if (mTargetSize > 0) {
        sampling = Math.min((float) width / mTargetSize, (float) height / mTargetSize);
        if (sampling < 1) {
            //targetSize bigger than resource width or height, decrease radius, not sampling
            radius = (int) (mRadius * sampling);
            sampling = 1;
        }
    }

    int scaledWidth = (int) (width / sampling);
    int scaledHeight = (int) (height / sampling);

    Bitmap bitmap = mBitmapPool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    canvas.scale(1 / sampling, 1 / sampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(source, 0, 0, paint);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        try {
            bitmap = RSBlur.blur(mContext, bitmap, radius);
        } catch (RSRuntimeException e) {
            L.report(e);
            bitmap = FastBlur.blur(bitmap, radius, true);
        }
    } else {
        bitmap = FastBlur.blur(bitmap, radius, true);
    }

    return BitmapResource.obtain(bitmap, mBitmapPool);
}
 
开发者ID:ykrank,项目名称:S1-Next,代码行数:43,代码来源:BlurTransformation.java


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