Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Cut image through code in mac os

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 522
    Comment on it

    Method to cut image in Objective-c/cocoa (OSX)

    -(IBAction)cutItem:(id)sender
    {
        hasBeenDragged = NO;
        NSImage *_sourceImage = [self image];
        float width = selectedArea.size.width;
        float height = selectedArea.size.height;
        float centerX = ([self frame].size.width/2)-width/2;
        float centerY = ([self frame].size.height/2)-height/2;
        [_sourceImage lockFocus];
        [[NSColor blackColor] set];
        NSRectFill(NSMakeRect(centerX, centerY, selectedArea.size.width, selectedArea.size.height));
        [_sourceImage unlockFocus];
        [self setImage:_sourceImage];
        [self setNeedsDisplay:YES];
        selectedArea = NSZeroRect;
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: