about 11 years ago
-(NSImage*)rotateImage:(CGFloat)degrees { NSImage *_image = [YourImageController image]; NSRect imageBounds = {NSZeroPoint, [_image size]}; NSBezierPath *boundsPath = [NSBezierPath bezierPathWithRect:imageBounds]; NSAffineTransform *transform = [NSAffineTransform transform]; [transform rotateByDegrees:degrees]; [boundsPath transformUsingAffineTransform:transform]; NSRect rotatedBounds = {NSZeroPoint, [boundsPath bounds].size}; NSImage *rotatedImage = [[NSImage alloc] initWithSize:rotatedBounds.size]; imageBounds.origin.x = NSMidX(rotatedBounds) - (NSWidth (imageBounds) / 2); imageBounds.origin.y = NSMidY(rotatedBounds) - (NSHeight (imageBounds) / 2); transform = [NSAffineTransform transform]; [transform translateXBy:+(NSWidth(rotatedBounds)/ 2) yBy:+(NSHeight(rotatedBounds) / 2)]; [transform rotateByDegrees:degrees]; [transform translateXBy:-(NSWidth(rotatedBounds)/ 2) yBy:-(NSHeight(rotatedBounds) / 2)]; [rotatedImage lockFocus]; [transform concat]; [_image drawInRect:imageBounds fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0] ; [rotatedImage unlockFocus]; return rotatedImage; }
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)