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

The following examples show how to use com.bumptech.glide.load.resource.bitmap.TransformationUtils. 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
Source File: CropCircleWithBorderTransformation.java    From glide-transformations with Apache License 2.0 6 votes vote down vote up
@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 File: GlideRotateDimenTransformation.java    From android-slideshow with 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 File: RoundedCorners.java    From Silence with 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 File: GlideTransformUtils.java    From DevUtils with 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
Source File: GlideRoundTransform.java    From DrySister with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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
Source File: CropCircleTransformation.java    From glide-transformations with Apache License 2.0 4 votes vote down vote up
@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
Source File: CropSquareTransformation.java    From glide-transformations with Apache License 2.0 4 votes vote down vote up
@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 File: RoundedCorners.java    From Silence with 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);
}