Re: Rotated display of bitmap images?
Re: Rotated display of bitmap images?
- Subject: Re: Rotated display of bitmap images?
- From: Andreas Mayer <email@hidden>
- Date: Mon, 17 Jun 2002 20:44:49 +0200
Am Montag den, 17. Juni 2002, um 18:57, schrieb Dinu Gherman:
but at least in the code below everything else
(only a border) but not the image itself is rotated. And the
NSImage doc for the used method says:
[...] The composite is positioned and oriented according
to the current coordinate system. The image is rotated and
scaled as needed.
It does.
[...]
#import "MyImageView.h"
@implementation MyImageView
-(void)drawRect:(NSRect)rect
{
NSPoint p = NSMakePoint(NSMinX(rect), NSMinY(rect));
NSString *imgPath = @"/Users/dinu/Desktop/foo.jpg";
NSImage *img = [[NSImage alloc] initByReferencingFile: imgPath];
[self setImageFrameStyle: NSImageFrameGrayBezel];
[self setImage: img];
[self setFrameRotation:10.0];
Use NSAffineTransform instead:
NSAffineTransform *transform = [NSAffineTransform transform];
[transform rotateByDegrees:-angle];
# draw a border
[[NSColor grayColor] set];
[NSBezierPath setDefaultLineWidth: 5];
[NSBezierPath strokeRect: rect];
[img drawAtPoint: p
fromRect: rect
operation: NSCompositeDestinationAtop
fraction: 1.0];
[super drawRect: rect];
}
@end
If you want to additionally scale the image, try
drawInRect:fromRect:operation:fraction:
bye. Andreas.
_______________________________________________
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.