• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Rotated display of bitmap images?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Rotated display of bitmap images?
      • From: Dinu Gherman <email@hidden>
References: 
 >Rotated display of bitmap images? (From: Dinu Gherman <email@hidden>)

  • Prev by Date: CGI in COCOA example
  • Next by Date: Webdings et.al. ?
  • Previous by thread: Rotated display of bitmap images?
  • Next by thread: Re: Rotated display of bitmap images?
  • Index(es):
    • Date
    • Thread