Coder Social home page Coder Social logo

x/y must be >= 0 about cropiwa HOT 4 OPEN

steelkiwi avatar steelkiwi commented on June 1, 2024
x/y must be >= 0

from cropiwa.

Comments (4)

longpham2310 avatar longpham2310 commented on June 1, 2024 1

I make it workaround like this.

public Bitmap applyCropTo(Bitmap bitmap) {
        int x = findRealCoordinate(bitmap.getWidth(), cropRect.left, imageRect.width());
        int y = findRealCoordinate(bitmap.getHeight(), cropRect.top, imageRect.height());
        int width = findRealCoordinate(bitmap.getWidth(), cropRect.width(), imageRect.width());
        int height = findRealCoordinate(bitmap.getHeight(), cropRect.height(), imageRect.height());

        if (x < 0) {
            x = 0;
        }
        if (y + height >= bitmap.getHeight()) {
            y = bitmap.getHeight() - height;
        }
        
        Log.d(TAG, "x/y/with/height : " + x + "/" + y + "/" + width + "/" + height);
        Bitmap immutableCropped = Bitmap.createBitmap(bitmap,
                x,
                y,
                width,
                height);
        return immutableCropped.copy(immutableCropped.getConfig(), true);
    }

from cropiwa.

smilecs avatar smilecs commented on June 1, 2024

I will suppose x to be width? have you tried checking what width is returned so compare and see first?

from cropiwa.

zhangzhichaolove avatar zhangzhichaolove commented on June 1, 2024

CropImageTask -> doInBackground -> IOException changed to catch (Exception e) {
             Return e;
         }

CropArea -> applyCropTo (Bitmap bitmap) -> changed to public Bitmap applyCropTo (Bitmap bitmap) throws IllegalArgumentException

Above can prevent crashes.

CropIwaView -> preceded by judgment: crop (CropIwaSaveConfig saveConfig) {
     If (imageView.getImageRect (). Left == -1 || imageView.getImageRect (). Left == 0) {
             Return;
         }
}
If the crop method has not yet completed, it will be returned, of course, here you can do other operating logic.

from cropiwa.

flasher297 avatar flasher297 commented on June 1, 2024

I've fixed this issue with posting message on UI thread. It seems that this exception is raised when sixe of view is still not set.

 cropView.post(() ->
                cropView.crop(new CropIwaSaveConfig.Builder(croppedFileDestination)
                        .setCompressFormat(Bitmap.CompressFormat.JPEG)
                        .setQuality(80)
                        .build()));

from cropiwa.

Related Issues (20)

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.