Code Monkey home page Code Monkey logo

croppernocropper's People

Contributors

jayrambhia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

croppernocropper's Issues

Force not less than width or height

How to force to imageview to not be reduced less than width and height of the CropperView at the same time? I have tried to use isMakeSquare and then setting up back to the initial position but it's not clear. Please help! I try too with setMinZoom(0)

save translations done on the image and restore back

Hi ,
Thanks for the awesome work on the library. I wish to use the same thing just like instagram does for multi image cropping, my use case is

  1. The user will be shown a list of images from gallery anf the cropperview just like instagram .
  2. I want the user to select the image and do his opertations like scaling postioning in the cropperview
  3. when the user clicks on another image we save the translations and scaling done on the image and restore back when the user clicks on the same image again.

please suggest if this thing is possible. I am short on time as well here , so would appriciate a quick response.

getCroppedBitmap has a private access

In v0.2.0 I'm not able to use getCroppedBitmap() method anymore. I'm getting the error that getCroppedBitmap() has a private access. How should I get the cropped bitmap now?

Thanks in advance

question

how get bitmap image after crop

getCroppedBitmap returns BitmapResult and not a Bitmap

Hi dear,

I was utilizing your great library "nocropper" for some of my need, i was working with the library on one of my PC where i get the Bitmap using getCroppedBitmap as " Bitmap bm = cropperView.getCroppedBitmap()", it went find and i got the resultant bitmap. But now i am working with the same library and code on my other PC where i get a weird error saying getCroppedBitmap returns BitmapResult so you have to get a BitmapResult and not a Bitmap. While i need a Bitmap so i can use it frther but I'm unable to get it. what could be the issue. can you please throw some light on it.

On zooming less than min zoom the image is panned to center

Set min zoom to 0.8f.
Take an image which is really long in height, i'm using the below image.

Issue seems to be in on up
private boolean onUp(){
...
if (showAnimation()) {

            animateAdjustmentWithScale(tx, xx, ty, **ty,** scaleX, mMinZoom);

        } else {
            matrix.reset();
            matrix.setScale(mMinZoom, mMinZoom);
            matrix.postTranslate(xx, **ty**);
            setImageMatrix(matrix);
            invalidate();
            if (DEBUG) {
                Log.i(TAG, "scale after invalidate: " + getScale(matrix));
            }
        }
        return true;
    }

...

Should solve the issue,

screenshot_20170420-125705

no panning with min zoom

when i set min zoom to suppose 1.25 of the height, it works fine on supporting minimum zoom but after minimum zooming, I cannot pan the image within the square. The image snaps back to the minimum zoom set with center aligned.

com.fenchtose.nocropper.CropperView height issue

it seems your are calculating the CropperView based on the width of the view. Now the problem is I'm not able to make the view center in the screen.

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/bottom_frame"
    android:layout_alignParentTop="true" >
    <com.fenchtose.nocropper.CropperView
        android:background="#ff282828"
        android:id="@+id/imageview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:grid_opacity="0.8"
        app:grid_thickness="1.1dp"
        app:grid_color="@color/colorAccent"/>
    <ImageView
        android:id="@+id/snap_button"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_margin="16dp"
        android:padding="8dp"
        android:layout_gravity="left|bottom"
        android:background="@drawable/black_transp_circ_ripple"
        android:scaleType="center"
        android:src="@mipmap/ic_crop_free_white_24dp"/>
    <ImageView
        android:id="@+id/rotate_button"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:padding="8dp"
        android:layout_margin="16dp"
        android:layout_gravity="right|bottom"
        android:background="@drawable/black_transp_circ_ripple"
        android:scaleType="center"
        android:src="@mipmap/ic_rotate_right_white_24dp"/>
</FrameLayout>
<LinearLayout
    android:id="@+id/bottom_frame"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:background="#ff212121"
    android:padding="9dp"
    android:layout_alignParentBottom="true"
    android:gravity="center_vertical"
    android:orientation="horizontal">
    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="Upload Image"
        android:id="@+id/image_button"/>
    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="Crop"
        android:id="@+id/crop_button"/>
</LinearLayout>
</RelativeLayout>

screenshot_2015-11-19-02-18-49

Resizing final image

Hi, thanks for great library. How can i change the size final image px. For example when i use square final image gives 720x720 , or when i crop rectangle height or width 720px. But i want to change this with 1280 or etc. How can i do? thank you.

Image Rotate issue on Some devices

we used implementation 'com.fenchtose.nocropper:nocropper:0.3.1' image rotate when we select image on samsung devices Samsung Galaxy A50 image rotate.

minimum zoom related to Image width and height.

How can I set minimum zoom as per my Image width (For multiple Image selection)? Just like Instagram

Case 1: If I select a single image then Image should be zoom minimum as possible (Default).

Case 2: If I am selecting multiple Images then Images should be zoom minimum to image width (Just like cropToCenter()).

Cropped Bitmap also take black portion which is not part of Image .

CroppedBitmap also take black line which is not part of Image .
How to remove that black portion

It happens with most potrait Images.

BitmapResult bitmapResult = ivSelectedImage.getCroppedBitmap();

           if (bitmapResult.getState() == CropState.SUCCESS) {
            bitmapResult.getBitmap();
             
           }

Resize Bitmap In replaceBitmap(bitmap) Method

Thanks for Awesome work on NoCropper.
Really Amazing Library to Achieve decent crop function.

In last update it's introduce replaceBitmap() method , this is the thing that i was looking for.
After block "Bitmap is of different size. Not replacing" part in replaceBitmap method it's resize bitmap for the first time, then it's work fine.

how to make it work fine ? for all the time including very first time.

Zoom not working inside Scrollview/Nested Scrollveiw

zoom not working inside the scrollview and the gesture not responding inside the scrollview/Nested scrollview

please find the below code: and also tested with CropperView also its not working the view is now just an image view. Not working in scroll sconatiner

   <android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

     <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/frame_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.fenchtose.nocropper.CropperImageView
                android:id="@+id/cropper_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/transparent_purple"
                app:nocropper__grid_color="@color/colorAccent"
                app:nocropper__grid_opacity="0.8"
                app:nocropper__grid_thickness="0.8dp"
                android:nestedScrollingEnabled="false"
                app:nocropper__padding_color="@color/transparent_purple" />

            <android.support.v7.widget.AppCompatImageView
                android:id="@+id/snap_button"
                android:layout_width="@dimen/margin_30"
                android:layout_height="@dimen/margin_30"
                android:layout_gravity="bottom|start"
                android:layout_margin="@dimen/margin_20"
                android:src="@drawable/ic_image_enlarge" />

        </FrameLayout>

    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

how to get "bitmap" from our image-view(CropperView)?

I have tried to get "bitmap" from CropperView like our regular android image-view.
In android, we get "bitmap" using the following line
BitmapDrawable drawable = (BitmapDrawable) iv_image.getDrawable(); Bitmap image = drawable.getBitmap();
I have tried same thing with CropperView but getDrawable() method is not working.
I want bitmap for the change its brightness. I get the bitmap from CropperView using Bitmap bitmap = mImageView.getCroppedBitmap(); but unable to change brightness for image-view using this bitmap.

OR Simple, please tell me how to change brightness for image-view using CropperView.

Image is not displaying when i get image path from another activity

Hi,

Thanks for sharing this library.

I'm facing a issue in the following scenario,

  1. Image path is taken from ActivityA, now i pass the path ActivityA to MainActivity(Your Cropper MainAcitivity)
    2.I load the path value directly in loadNewImage(). (eg. loadNewImage(getIntent().getExtras().getString("IMAGE_PATH"))
  2. Now the image was displayed, while i perform zoom option the image was gone, when i perform touch on the gird, the actual image is displayed but i can't able to perform image zooming.
  3. But i can able to do zooming and cropping functionality by clicking Upload Image

For your ref, i added the code snipped what i had done,

public class BaseActivity extends Activity {

private static final int REQUEST_GALLERY = 21;
public static String imagePath = "";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base);

    findViewById(R.id.image_button).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            startGalleryIntent();
        }
    });
    findViewById(R.id.crop_button).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (!imagePath.isEmpty()) {
                startActivity(new Intent(BaseActivity.this, MainActivity.class).putExtra("IMAGE_PATH", imagePath));
            }
        }
    });

}

private void startGalleryIntent() {
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(intent, REQUEST_GALLERY);
}

@Override
public void onActivityResult(int requestCode, int responseCode, Intent resultIntent) {
    super.onActivityResult(requestCode, responseCode, resultIntent);

    if (responseCode == RESULT_OK) {
        imagePath = BitmapUtils.getFilePathFromUri(this, resultIntent.getData());
        // loadNewImage(absPath);
    }
}

}

No grid when moving

Hey there,

With the following configuration the CropperView still shows a grid view when moving the image even though the grid_color, thickness are set to make it transparant.

Is there a way to hide the grid lines when moving the image? For us this is not relevant since we don't try to align buildings and stuff :)

<com.fenchtose.nocropper.CropperView
    android:id="@+id/userImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:background="@color/white"
    app:nocropper__grid_color="@android:color/transparent"
    app:nocropper__grid_thickness="0dp"
    app:nocropper__padding_color="@color/white" />
When not moving when moving the image
Screenshot_1588080912 Screenshot_1588080914

java.lang.IllegalArgumentException: y must be >= 0

Version 0.1.7 works as intented but after updating v0.2 I get this exception.

Fatal Exception: java.lang.IllegalArgumentException: y must be >= 0
       at android.graphics.Bitmap.checkXYSign(Bitmap.java:366)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:683)
       at com.fenchtose.nocropper.CropperImageView.getCroppedBitmap(SourceFile:861)
       at com.fenchtose.nocropper.CropperImageView.cropBitmap(SourceFile:679)
       at com.fenchtose.nocropper.CropperView.getCroppedBitmap(SourceFile:100)

min zoom is not working

I'm ok with setMaxZoom, but unfortunately setMinZoom is not working!
Here is my code

// Set Bitmap cropperView.setImageBitmap(bitmap); // Set Max and Min Cropping cropperView.setMaxZoom(1.5f); cropperView.setMinZoom(0.8f);

Applying cropping to the Rotated image was not working

Hi, thanks for the library it was cool and have the features i needed.
I was facing an issue found this in your sample app too.
When i was trying to crop the original image after setting the rotation it was not working.
pls check once and let me know any possible solution.

Note :
It was working with BitmapResult result = mImageView.getCroppedBitmap();
But not working when i try to crop the original image from this method prepareCropForOriginalImage(); from your sample

Padding color doesn't get set from the setPaddingColor function

I tried to use the setPaddingColor(color) function for the CropperView but it isn't saving it with the padding color. However, if I set the padding color from the layout file, then it works.

So I looked in your code and in your function (in CropperView), setPaddingColor doesn't set the padding color for the mImageView.

On my side I just modified your code to fix it but just letting you know too. :)

Support for Landscape Layout

Currently, the CropperView offsets the height based on width. This wouldn't work properly in landscape scenario. Add support for Landscape layout.

Not works when the image leaves the border of CropperView

When we zoom the image in the CropperView and moves the image ...the image in the CropperView leaves the border and after this if we crop the image it gives this error....

java.lang.IllegalArgumentException: x + width must be <= bitmap.width()

Custom crop frame

Hi @jayrambhia
Thanks for sharing this library.

It´s possible change the ratio of the crop frame?
Now its a square, but i need crop with a vertical rectangle form.
The output size now it´s 960x960, it´s possible change this too?¿

Thanks ind advanced :))

Sergio

Image initially zoomed

Is there any possibility to avoid image to be zoomed initially to 1:1 instead of its real size f.e. 16:9?

Imageview or Bitmap Rotate From Center Using replaceBitmap(mBitmap)

@jayrambhia
Hello,

Yes, it's work fine when you wants to rotate bitmap with setBitmap(rotateBitmap(mOrigBitmap)), but when you scale image then do rotate, it's reassign bitmap to CropperView, so i like to use replaceBitmap(rotatedBitmap) for avoiding reassign bitmap, then i figured out it wan't rotate from center point as it has to.

How to get rid of this strange rotate behavior ?

Flow for this.

  1. cropper.setImageBitmap(mOrigBitmap);
  2. scaling CropperView Image
  3. Bitmap rotatedBitmap= rotateBitmap(mOrigBitmap); -> Applying rotate using rotateBitmap?
  4. cropper.replaceBitmap(rotatedBitmap); -> it's assign bitmap like it's rotate from top-left corner !

Desire result is rotatedBitmap should be replace with reference to center points of scaled bitmap with latest matrix.

Application crashes after drag the image out of the screen

I did the following steps:

  1. first, select a 9:16(w:h) image,
  2. click make it fit to screen,
  3. then, scale it a little use two fingers
  4. drag it up out of the screen
  5. crop the image

after that, it crashes.

update:

it will crash after i scale it smaller but not to fit center.
steps:

  1. select a pic
  2. scale it a little smaller
    3.crop
    then, it crashes.

CropperView on ViewPager Swipe problem

I have a problem in my CropperView, because the view Touch event don't prevent the ViewPager swipe, and this issue, makes it difficult to resize image.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.