• 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: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…)


  • Subject: Re: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…)
  • From: Jerry Krinock <email@hidden>
  • Date: Wed, 17 Dec 2014 04:52:43 -0800

I think I did what the "High Resolution Guidelines for OS X” document suggested for drawing offscreen vector images.  See code snip below.

The result looks the same to me.  It’s OK with the old code, and OK with the new code.

To help me understand what I’m doing, I would appreciate if someone please elaborate on this quote from the documeent:

“If your app uses -lockFocus: … either you’ll get a low resolution NSImage object that looks incorrect when drawn, or you’ll get a 2x image that has more pixels in its bitmap than you are expecting”

• Are these “either” the only two possible results, or is there a third possibility, that it will work properly?

• Regarding "a low resolution NSImage object that looks incorrect when drawn”, does that mean that it looks grossly incorrect, like, say, the image is scaled down and squashed into one quadrant, or does it just mean that it will look fuzzy on a Retina display?

• What does "a 2x image that has more pixels in its bitmap” mean?  I thought that a 2x image is expected to have more pixels in its bitmap.

Jerry

…
NSImage* image ;
if ([NSImage respondsToSelector:@selector(imageWithSize:flipped:drawingHandler:)]) {
    // OS X 10.8 or later
    image = [NSImage imageWithSize:size
                           flipped:NO
                    drawingHandler:^(NSRect dstRect) {
                        [self drawStyle:style
                                 length:length
                                  color:color] ;
                        return YES ;
                    }] ;
}
else {
    image = [[NSImage alloc] initWithSize:size] ;
    [image lockFocus] ;
    [self drawStyle:style
             length:length
              color:color] ;
    [image unlockFocus] ;
}


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…)
      • From: Ken Thomases <email@hidden>
References: 
 >Why use NSCustomImageRep for drawing in code in NSImage? (From: Jerry Krinock <email@hidden>)
 >Re: Why use NSCustomImageRep for drawing in code in NSImage? (From: Ken Thomases <email@hidden>)
 >Re: Why use NSCustomImageRep for drawing in code in NSImage? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: OSAScriptController's stopScript action
  • Next by Date: Re: Observing changes in Table
  • Previous by thread: Re: Why use NSCustomImageRep for drawing in code in NSImage?
  • Next by thread: Re: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…)
  • Index(es):
    • Date
    • Thread