cocoa - How to draw a rounded NSImage -
I try to create an NSImage
or NSImageCell
with rounded corners I am doing a inside NSTableView
. I can not get anything to work. The best part here is that my custom nscell
:
- (zero) drawerwirewrightframe: (NSRact) frame Inview: (NSVUU) * Controlview (if (ThumbnailLink) {NSURL * url = [NSURL URLWithString: thumbnailLink]; if (url) {nsrttffrem = [auto_imageFrameForInteriorFrame: frame]; NSImage * image = [[NSImage alloc] initWithContentsOfURL: url ]; [Image setscales when resized: Yes]; [Image set size: NSMakeSize (IMAGE_HEIGHT, IMAGE_WIDTH)]; [NSGraphicsC Ontext saveGraphicsState]; ImageFrame = NSInsetRect (picture frame, 1, 1); NSBZIREPT * clippath = [NSBZearpathBeaserPathwithSteath: Image Frame Corner: 5.0]; [clippath set wading rule: NSEOOWDingArail]; [clippath adclip]; [NSGraphicsContext restorationGraphicsState]; [ Image drawInRect: imageFrame fromRect: NSMakeRect (0, 0, 0, 0) Operation: NSCompositeSourceIn fraction: 1.0]; [image release];}} ...
?
Draws your image Other clips need to be kept in the set, and after that the context has to be restored. Besides, I do not think you want to use "these" composites, but rather on "over" if you just want to make your image normal Keeping in mind the destination without ambiguity. Try to do something like this:
[Save NSFX contentGraphicsState]; NSBezierPath * Path = [NSBJairpath BezierPathwithWithRecordCourt: Image Frame x radius 5 yRadius: 5]; [Path adclip]; [Image drawInRect: imageFrame fromRect: NSZeroRect Operations: NSCompositeSourceOver fraction: 1.0]; [NSGraphicsContext ReplaceGraphicsState];
Comments
Post a Comment