Giter Site home page Giter Site logo

Support for rotation about scissors HOT 7 CLOSED

rohanmahale avatar rohanmahale commented on July 4, 2024 4
Support for rotation

from scissors.

Comments (7)

ihsanbal avatar ihsanbal commented on July 4, 2024 2

@rohanmahale this lines solved my rotation problem in CropView
` public void rotate(ROTATE rotation) {

    transform.reset();
    float degree = 0;

    switch (rotation.getRotationCode()) {
        case 0:
            degree = 90f;
            break;
        case 1:
            degree = -90f;
            break;
    }
    transform.postRotate(getRotation() + degree);
    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), transform, true);
    invalidate();
    resetTouchManager();
}

public enum ROTATE {
    RIGHT(0), LEFT(1);

    private final int i;

    ROTATE(int i) {
        this.i = i;
    }

    public int getRotationCode() {
        return i;
    }
}`

from scissors.

eveliotc avatar eveliotc commented on July 4, 2024

@rohanmahale as you might have noticed crop extension returns a Future so you can implement your callbacks/notification mechanisms on top of it, in example we use rxjava to wrap it and get notified when it completes (you can see how on https://github.com/lyft/scissors/blob/master/scissors-sample/src/main/java/com/lyft/android/scissorssample/MainActivity.java#L83-L89). Rotate was not part of our requirements, I agree it could be useful for third parties.

For both enhancement requests we don't have plans at this point but PRs are welcome :)

from scissors.

eveliotc avatar eveliotc commented on July 4, 2024

Renaming this for rotation only, callbacks ticket is now #23

from scissors.

rharter avatar rharter commented on July 4, 2024

My two cents: I think it makes sense for rotation to live in the loader, not the crop view. For instance, a Picasso Transformation can be applied that will rotate the image as needed before the CropView receives it.

I think that is ideal since rotation within the crop view will complicate the actual cropping (mapping of coordinates) and isn't the aim of the library.

from scissors.

nathanjones avatar nathanjones commented on July 4, 2024

@rharter I would agree that reading EXIF orientation data should probably be handled by the loader, a Picasso Transformation is perfect for that, but that's not necessarily the only time you would want to rotate an image.

In this issue, @rohanmahale wasn't entirely clear what his goal was, but rotation could mean having three buttons on an interface, one for rotate left, one for rotate right, and one to crop, which would usually finalize the image editing. That's definitely a useful feature, and a common pattern, but whether it's inside the scope of this library is the real question.

It would be nice to have certain extension features, like rotating, as separate gradle packages that could be included to extend the core functionality of Scissors.

from scissors.

rharter avatar rharter commented on July 4, 2024

@nathanjones I think the use case you're describing could be easily accomplished by using the image loader's transformation apis.

For instance, you could have your Picasso loader configured like so

public void rotateLeft() {
  rotation = (rotation - 90) % 360;
  reloadImage();
}

public void rotateRight() {
  rotation = (rotation + 90) % 360;
  reloadImage();
}

public void reloadImage() {
  cropView.extensions()
    .using(new PicassoBitmapLoader(Picasso.with(getContext(), new RotateTransformation(rotation))
    .load(url);
}

That being said, this doesn't allow for things like animating the rotation, so perhaps it does make sense to look at this if it's decided that it's in scope for the library. It might be as simple as applying a rotation or matrix to the canvas before drawing, and that might not be terrible considering the crop method draws with the same method onto a canvas.

from scissors.

dschaller avatar dschaller commented on July 4, 2024

Thank you for you contribution to this repository.

Closing this contribution as this repository is being archived.

from scissors.

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.