Re: Rotated display of bitmap images?
Re: Rotated display of bitmap images?
- Subject: Re: Rotated display of bitmap images?
- From: Dinu Gherman <email@hidden>
- Date: Tue, 18 Jun 2002 10:10:35 +0200 (CEST)
Ok, I ended up with the code below which does exactly
what I want. Maybe it's also useful for others...
Thanks Edwin and Andreas!
Dinu
-(void)drawRect:(NSRect)rect
{
NSString *imgPath = @"/Users/dinu/Desktop/foo.jpg";
NSImage *img = [[NSImage alloc] initByReferencingFile: imgPath];
NSSize size = [img size];
NSPoint center = NSMakePoint(NSMidX(rect), NSMidY(rect));
NSAffineTransform *transform = [NSAffineTransform transform];
// set style and call superclass' drawRect without drawing the image
[self setImageFrameStyle: NSImageFrameGrayBezel];
[self setImage:nil];
[super drawRect: rect];
// prepare and set image transformation, then draw transformed image
[transform translateXBy: center.x yBy: center.y];
[transform rotateByDegrees: 45.0];
[transform translateXBy: -size.width/2.0 yBy: -size.height/2.0];
[transform concat];
[self setImage: img];
[img drawAtPoint: NSZeroPoint
fromRect: NSZeroRect
operation: NSCompositeSourceOver
fraction: 1.0];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.