Re: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…)
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