• 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: "John C. Randolph" <email@hidden>
  • Date: Tue, 18 Jun 2002 10:53:31 -0700

On Tuesday, June 18, 2002, at 01:10 AM, Dinu Gherman wrote:

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];

Two things:

1) this is a memory leak. You're creating a new NSImage from the file every time -drawRect: is called.

2) I wouldn't create a new transform every time, either. Set it up and re-use it.

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];

This is redundant after the first time you call it.

-jcr


John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
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.

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

  • Prev by Date: Re: [Q] Help system
  • Next by Date: Re: [Q] Help system
  • Previous by thread: Re: Rotated display of bitmap images?
  • Next by thread: Re: Rotated display of bitmap images?
  • Index(es):
    • Date
    • Thread