Giter Club home page Giter Club logo

Comments (7)

ruslanskorb avatar ruslanskorb commented on July 29, 2024

Hi @dyadenkor,

Rectangle mode is the custom mode.
You need to set cropMode to RSKImageCropModeCustom and implement data source methods.

To support the rotation when cropMode is RSKImageCropModeCustom you must implement the data source method imageCropViewControllerCustomMovementRect:.

Then avoidEmptySpaceAroundImage will work properly.

from rskimagecropper.

dyadenkor avatar dyadenkor commented on July 29, 2024

Thanks, will try and will tell you the result. Thanks!

from rskimagecropper.

dyadenkor avatar dyadenkor commented on July 29, 2024

I'he tried. https://www.dropbox.com/s/laralbs0d0fewjm/Screenshot%202015-03-13%2021.33.15.png?dl=0

What I am doing wrong?

#pragma mark - Action handling

  • (void)onAddPhotoButtonTouch:(UIButton *)sender
    {
    UIImage *photo = [UIImage imageNamed:@"photo"];
    RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:photo cropMode:RSKImageCropModeCustom];
    imageCropVC.avoidEmptySpaceAroundImage = YES;
    imageCropVC.rotationEnabled = YES;
    imageCropVC.dataSource = self;
    imageCropVC.delegate = self;
    [self.navigationController pushViewController:imageCropVC animated:YES];
    }

#pragma mark - RSKImageCropViewControllerDataSource

// Returns a custom rect for the mask.

  • (CGRect)imageCropViewControllerCustomMaskRect:(RSKImageCropViewController *)controller
    {
    CGFloat viewWidth = CGRectGetWidth(self.view.frame);
    CGFloat viewHeight = CGRectGetHeight(self.view.frame);

    CGRect maskRect = CGRectMake(0,
    (viewHeight - viewWidth) * 0.25f,
    viewWidth,
    viewWidth * 0.75f);

    return maskRect;
    }

// Returns a custom path for the mask.

  • (UIBezierPath *)imageCropViewControllerCustomMaskPath:(RSKImageCropViewController *)controller
    {
    CGRect rect = controller.maskRect;
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRect:rect];
    return maskPath;
    }

// Returns a custom rect in which the image can be moved.

  • (CGRect)imageCropViewControllerCustomMovementRect:(RSKImageCropViewController *)controller
    {
    return [self imageCropViewControllerCustomMaskRect:controller];
    }

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on July 29, 2024

You should calculate and return the correct movement rect according to the current values of the parameters, such as the angle of rotation.
It's a usage question. You can ask about it on stack overflow.

from rskimagecropper.

pronebird avatar pronebird commented on July 29, 2024

We should include rotation in sample app, I think not many understand what movement rect is.

from rskimagecropper.

dyadenkor avatar dyadenkor commented on July 29, 2024

I understand what is this, but I can't understand how could I calculate it. I saw many calculations in sources, could you explain, please in words these processes. Thanks :)

from rskimagecropper.

ruslanskorb avatar ruslanskorb commented on July 29, 2024

@dyadenkor, you can read about these processes here

@pronebird, what kind of example would you add?

from rskimagecropper.

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.