• 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: Compositing text onto an NSImageView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compositing text onto an NSImageView


  • Subject: Re: Compositing text onto an NSImageView
  • From: John Hörnkvist <email@hidden>
  • Date: Fri, 8 Jun 2001 12:43:07 +0200

On Friday, June 8, 2001, at 09:49 AM, Will Price wrote:

I have an NSImageView with an image in it. I now want to place text
overlayed on top of the image rotated at a 45 degree angle similar to
a watermark.

I'd do something like this:

@interface MyImageView:NSImageView
{
NSAttributedString* text;
}
- (void)drawRect:(NSRect)aRect;
@end

@implementation MyImageView

- (void)drawRect:(NSRect)aRect
{

[super drawRect:aRect];

[NSGraphicsContext saveGraphicsState];
{
NSAffineTransform* transform=[NSAffineTransform transform]; [transform rotateByDegrees:
45];
[transform concat];

NSClipRect(aRect);
// I think you may want to flip the view before drawing.
[text drawAtPoint:NSMakePoint(0,0)];
}
[NSGraphicsContext restoreGraphicsState];
}
@end

I wrote this in the letter, so it has never been compiled, and is completely untested.



Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com


References: 
 >Compositing text onto an NSImageView (From: Will Price <email@hidden>)

  • Prev by Date: Re: OpenGL Examples in Cocoa
  • Next by Date: Re: Compositing text onto an NSImageView
  • Previous by thread: Compositing text onto an NSImageView
  • Next by thread: Re: Compositing text onto an NSImageView
  • Index(es):
    • Date
    • Thread