Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (NSSize)pixelSize
- {
- CGImageRef CGImage = [self CGImageForProposedRect:nil context:nil hints:nil];
- NSBitmapImageRep *bmp = [[NSBitmapImageRep alloc] initWithCGImage:CGImage];
- return NSMakeSize(bmp.pixelsWide, bmp.pixelsHigh);
- }
- NSColor *color = [NSColor redColor];
- NSPDFImageRep* rep = self.representations.lastObject;
- return [NSImage imageWithSize:self.pixelSize flipped:NO drawingHandler:^BOOL (NSRect dstRect)
- {
- [[NSGraphicsContext currentContext] saveGraphicsState];
- CGFloat lineWidth = 1.;
- NSBezierPath *strokePath = [NSBezierPath bezierPathWithOvalInRect:NSInsetRect(dstRect, lineWidth/2., lineWidth/2.)];
- [[NSColor whiteColor] set];
- [strokePath setLineWidth:lineWidth];
- [strokePath fill];
- [color set];
- [rep drawInRect:dstRect fromRect:NSZeroRect operation:NSCompositeSourceIn fraction:1 respectFlipped:YES hints:@{NSImageHintInterpolation: @(NSImageInterpolationHigh)}];
- [color set];
- [strokePath stroke];
- [[NSGraphicsContext currentContext] restoreGraphicsState];
- return YES;
- }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement