about 9 years ago
If you want to crop the image without changing its quality in Objective-c/cocoa (OSX) then you can use the following method
-(IBAction)crop:(id)sender{ hasBeenDragged = NO; NSImage *_sourceImage = [self image]; float width = selectedArea.size.width; float height = selectedArea.size.height; float xPos = selectedArea.origin.x; float yPos = selectedArea.origin.y; float centerX = ([self frame].size.width/2)-width/2; float centerY = ([self frame].size.height/2)-height/2; NSImage *_alteredImage = [[NSImage alloc]initWithSize:[_sourceImage size]]; [_alteredImage lockFocus]; [_sourceImage drawAtPoint:NSMakePoint(centerX,centerY) fromRect:NSMakeRect(xPos, yPos, width, height+50) operation:NSCompositeSourceOver fraction:1.0]; [_alteredImage unlockFocus]; [self setImage:_alteredImage]; [self setNeedsDisplay:YES]; }
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)