Java Code Examples for com.bumptech.glide.load.resource.bitmap.TransformationUtils

The following examples show how to use com.bumptech.glide.load.resource.bitmap.TransformationUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@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;
}
 
Example 2
Source Project: android-slideshow   Source File: GlideRotateDimenTransformation.java    License: MIT License 5 votes vote down vote up
@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);
}
 
Example 3
Source Project: Silence   Source File: RoundedCorners.java    License: GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 4
Source Project: DevUtils   Source File: GlideTransformUtils.java    License: Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 5
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
    Bitmap bitmap = TransformationUtils.centerCrop(pool, toTransform, outWidth, outHeight);
    return roundCrop(pool, bitmap);
}
 
Example 6
@Override
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
                           @NonNull Bitmap toTransform, int outWidth, int outHeight) {
  return TransformationUtils.circleCrop(pool, toTransform, outWidth, outHeight);
}
 
Example 7
@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);
}
 
Example 8
Source Project: Silence   Source File: RoundedCorners.java    License: GNU General Public License v3.0 4 votes vote down vote up
private Bitmap fitCenter(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
  return TransformationUtils.fitCenter(toTransform, pool, outWidth, outHeight);
}