First off: I want to use NSBezierPath
to draw some simple button artwork in my app, so I figure I should create an NSBitmapImageRep
, get the CGImage
, create an NSImage
from that, and then call setImage: on the button. Correct me if I'm wrong.
So I went to see how to create an NSBitmapImage
and found this:
**initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:**
Whoa.
Keeping in mind what I was looking for was something along the lines of an initWithSize:
, what should I put in for those values?
Any particular reason you're not simply creating a new NSImage
and drawing into it by bracketing your drawing code with focus locking like
NSImage* anImage = [[NSImage alloc] initWithSize:NSMakeSize(100.0, 100.0)];
[anImage lockFocus];
// Do your drawing here...
[anImage unlockFocus];
(The Cocoa Drawing Guide is your friend, btw)