类com.bumptech.glide.load.resource.bitmap.TransformationUtils源码实例Demo

下面列出了怎么用com.bumptech.glide.load.resource.bitmap.TransformationUtils的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
                           @NonNull Bitmap toTransform, int outWidth, int outHeight) {

  Bitmap bitmap = TransformationUtils.circleCrop(pool, toTransform, outWidth, outHeight);

  setCanvasBitmapDensity(toTransform, bitmap);

  Paint paint = new Paint();
  paint.setColor(borderColor);
  paint.setStyle(Paint.Style.STROKE);
  paint.setStrokeWidth(borderSize);
  paint.setAntiAlias(true);

  Canvas canvas = new Canvas(bitmap);
  canvas.drawCircle(
      outWidth / 2f,
      outHeight / 2f,
      Math.max(outWidth, outHeight) / 2f - borderSize / 2f,
      paint
  );

  return bitmap;
}
 
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
	Log.d(TAG, String.format("Height: %d Width: %d", toTransform.getHeight(), toTransform.getWidth()));
	if (toTransform.getHeight() >= toTransform.getWidth()){
		// Perform fit center here on un-rotated image.
		toTransform = TransformationUtils.fitCenter(toTransform, pool, outWidth, outHeight);
		return toTransform;
	}
	// Fit center using largest side (width) for both to reduce computation for rotate
	//noinspection SuspiciousNameCombination
	toTransform = TransformationUtils.fitCenter(toTransform, pool, outWidth, outWidth);
	return TransformationUtils.rotateImage(toTransform, 90);
}
 
源代码3 项目: Silence   文件: RoundedCorners.java
private Bitmap centerCrop(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
  final Bitmap toReuse     = pool.get(outWidth, outHeight, getSafeConfig(toTransform));
  final Bitmap transformed = TransformationUtils.centerCrop(toReuse, toTransform, outWidth, outHeight);

  if (toReuse != null && toReuse != transformed && !pool.put(toReuse)) {
    toReuse.recycle();
  }

  return transformed;
}
 
源代码4 项目: DevUtils   文件: GlideTransformUtils.java
@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
    Bitmap bitmap = TransformationUtils.centerCrop(pool, toTransform, outWidth, outHeight);
    return blurBitmap(mContext, bitmap, 20, outWidth, outHeight);
}
 
源代码5 项目: DrySister   文件: GlideRoundTransform.java
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
    Bitmap bitmap = TransformationUtils.centerCrop(pool, toTransform, outWidth, outHeight);
    return roundCrop(pool, bitmap);
}
 
@Override
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
                           @NonNull Bitmap toTransform, int outWidth, int outHeight) {
  return TransformationUtils.circleCrop(pool, toTransform, outWidth, outHeight);
}
 
@Override
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
                           @NonNull Bitmap toTransform, int outWidth, int outHeight) {
  this.size = Math.max(outWidth, outHeight);
  return TransformationUtils.centerCrop(pool, toTransform, size, size);
}
 
源代码8 项目: Silence   文件: RoundedCorners.java
private Bitmap fitCenter(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
  return TransformationUtils.fitCenter(toTransform, pool, outWidth, outHeight);
}
 
 类所在包
 类方法
 同包方法