cookie-cutter icon indicating copy to clipboard operation
cookie-cutter copied to clipboard

Circuler Crop Not working

Open smjunaidkhan opened this issue 7 years ago • 1 comments

Hello i wrote the code bellow but the issue is the result image is always Square not circle . Please let me know what i am missing.

regards

CookieCutterImageView cookieCutterImageView= (CookieCutterImageView) findViewById(R.id.ivCrop);
     //   cookieCutterImageView.setImageURI(Base64Coverter.carImageUriCropped);
        cookieCutterImageView.init();
        cookieCutterImageView.getParams().setShape(CookieCutterShape.CIRCLE);
        Button btn_cropWheel= (Button) findViewById(R.id.btn_cropWheel);
        btn_cropWheel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CookieCutterImageView cookieCutterImageView= (CookieCutterImageView) findViewById(R.id.ivCrop);
                Bitmap img= cookieCutterImageView.getCroppedBitmap();
                ImageView img_cropedWheel= (ImageView) findViewById(R.id.img_cropedWheel);
                img_cropedWheel.setImageBitmap(img);
                FileOutputStream out = null;
                try {
                    out = new FileOutputStream("/storage/emulated/0/wheel.png");
                    img.compress(Bitmap.CompressFormat.PNG, 100, out);
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    try {
                        if (out != null) {
                            out.close();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

smjunaidkhan avatar May 06 '17 18:05 smjunaidkhan

If you want to get circular image by using this then you must use this.

Bitmap bitmap = ivCrop.getCroppedBitmap();
Bitmap circularBitmap = ImageUtils.getCircularBitmap(bitmap);
img_cropedWheel.setImageBitmap(circularBitmap);

This will give your image in circle. Also you don't need to use this code

cookieCutterImageView.init();
cookieCutterImageView.getParams().setShape(CookieCutterShape.CIRCLE);

comment that lines.

Thanks.

PGAndroid avatar Dec 15 '17 07:12 PGAndroid