I have a CGContext and I tried to draw an image on it.
I have a NSImage * load that i used on other method .
NSImage *check = [[NSImage alloc] initWithContentsOfFile:@"check.icns"];
CGContextDrawImage(arg2, CGRectMake(0, 0, 145, 15), check);
But CGContext want a CGImage * how can I used my NSImage * ?
Thanks
You should consider just opening it as a
CGImagein this case, if that is all you will need it for. If anNSImageis what you need, then see-[NSImage CGImageForProposedRect:context:hints:]. This method may not require a copy, and it can produce aCGImagerepresentation ideal for drawing into the destination context.If needed, you can create a
NSGraphicsContextfrom aCGContextusing+[NSGraphicsContext graphicsContextWithGraphicsPort:flipped:].