I wish I would find an answer for this. I have searched and searched and couldn\'t the right answer. Here is my situation:
In a Mac OS Cocoa Application, I want to draw
I found your question here a bit late because I have the same problem. Perhaps Apples developer documentation can help you here. I have not tested it myself, but take a look at this document:
http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CocoaDrawingGuide/Images/Images.html
Roughly in the center of the document you will find the section "Creating a Bitmap". It tells you different ways of creating pixel data.