• 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: 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.

  • Follow-Ups:
    • Re: Rotated display of bitmap images?
      • From: "John C. Randolph" <email@hidden>
References: 
 >Re: Rotated display of bitmap images? (From: Andreas Mayer <email@hidden>)
 >Re: Rotated display of bitmap images? (From: Dinu Gherman <email@hidden>)

  • Prev by Date: Re: Protecting Software w/ Software License Keys...
  • Next by Date: Re: Protecting Software w/ Software License Keys...
  • Previous by thread: Re: Rotated display of bitmap images?
  • Next by thread: Re: Rotated display of bitmap images?
  • Index(es):
    • Date
    • Thread