I'm interested in creating an NSImageRep subclass that can hold double precision values. The standard NSBitmapImageRep can hold single precision floats, but chokes on doubles. I like that the NSBitmapImageRep exposes the data buffer for manipulation, and I'd like to retain the ability to manipulate the data in place rather than manipulate a separate buffer that I'll need to convert into an image for display.
I think subclassing is fairly straight forward except I'm not sure how to handle the most basic part: drawing the image. The documentation lists -draw as a method I need to implement, which makes sense, but what is the best way to draw a bitmap?
I saw one hesitant suggestion to draw lots of little rectangles, one per pixel presumably: How to Implement Custom Image representation for NSImage
Is there a more efficient approach? I've looked and can't find a worked example of a custom NSImageRep with bitmap data-- most examples use vector data.
Also, I find it interesting that the method to implement is simply -draw, and not any form of bounded draw. Is there a way to determine what the current clipping region is from within the NSImageRep or something to avoid drawing parts of the image that aren't necessary?