@@ -0,0 +1,3345 @@
+package jp.wasabeef.glide.transformations;%0A%0A/**%0A * Copyright (C) 2017 Wasabeef%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apublic class CropCircleWithBorderTransformation implements Transformation%3CBitmap%3E %7B%0A%0A    private BitmapPool mBitmapPool;%0A    private int borderWidth;%0A    private int borderColor;%0A%0A    public CropCircleWithBorderTransformation(Context context, int borderWidth,%0A                                              @ColorInt int borderColor) %7B%0A        this(Glide.get(context).getBitmapPool());%0A        this.borderWidth = borderWidth;%0A        this.borderColor = borderColor;%0A    %7D%0A%0A    public CropCircleWithBorderTransformation(BitmapPool pool) %7B%0A        this.mBitmapPool = pool;%0A    %7D%0A%0A    @Override%0A    public Resource%3CBitmap%3E transform(Resource%3CBitmap%3E resource, int outWidth, int outHeight) %7B%0A        Bitmap source = resource.get();%0A        int size = Math.min(source.getWidth(), source.getHeight());%0A%0A        int width = (source.getWidth() - size) / 2;%0A        int height = (source.getHeight() - size) / 2;%0A%0A        Bitmap bitmap = mBitmapPool.get(size, size, Bitmap.Config.ARGB_8888);%0A        if (bitmap == null) %7B%0A            bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);%0A        %7D%0A%0A        Canvas canvas = new Canvas(bitmap);%0A        Paint paint = new Paint();%0A        BitmapShader shader =%0A                new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);%0A        if (width != 0 %7C%7C height != 0) %7B%0A            // source isn't square, move viewport to center%0A            Matrix matrix = new Matrix();%0A            matrix.setTranslate(-width, -height);%0A            shader.setLocalMatrix(matrix);%0A        %7D%0A        paint.setShader(shader);%0A        paint.setAntiAlias(true);%0A%0A        float r = size / 2f;%0A        canvas.drawCircle(r, r, r, paint);%0A%0A        // add border%0A        int dstBitmapWidth = bitmap.getWidth() + borderWidth * 2;%0A        Bitmap borderedBitmap =%0A                Bitmap.createBitmap(dstBitmapWidth, dstBitmapWidth, Bitmap.Config.ARGB_8888);%0A        Canvas canvas1 = new Canvas(borderedBitmap);%0A        canvas1.drawBitmap(bitmap, borderWidth, borderWidth, null);%0A%0A        Paint paint1 = new Paint();%0A        paint1.setColor(borderColor);%0A        paint1.setStyle(Paint.Style.STROKE);%0A        paint1.setStrokeWidth(borderWidth);%0A        paint1.setAntiAlias(true);%0A%0A        canvas1.drawCircle(%0A                canvas1.getWidth() / 2,%0A                canvas1.getWidth() / 2,%0A                canvas1.getWidth() / 2 - borderWidth / 2,%0A                paint1%0A        );%0A%0A        bitmap.recycle();%0A%0A        return BitmapResource.obtain(borderedBitmap, mBitmapPool);%0A    %7D%0A%0A    @Override public String getId() %7B%0A        return %22CropCircleWithBorderTransformation(%22 +%0A                %22width=%22 + borderWidth + %22, color=%22 + borderColor + %22)%22;%0A    %7D%0A%7D

Add crop circle with border transformation (#136)