NSBitmapImage vs CGImageRef

What should I use for fast pixels operations? CGImageRef or NSBtimapImageRep or maybe OpenGL? I have been using quartz so far but it slow for me.

A few years ago, CGImage and NSBitmapImageRep got kinda linked in the underlying implementation. A NSBitmapImageRep isn't a CGImage, except that it kinda is, some of the time. (How's that for technical exactness?!?)


If you're talking about fast pixel operations as a way of modifying an image, neither CGImage nor NSBitmapImageRep really qualify. CVPixelBuffer is a lighter-weight structure for manipulating pixels, but as soon as you try to send it to the display, it's going to (potentially) go through several layers of API and/or translation, which may disqualify it as "fast".


If you have a need for a truly fast pixel-data-to-display path, I suspect your best choice would be to invest some effort in Metal.

Can you give some good core video tutorials and can opengl replace matal for that task

Usually, those tutorials are pretty good (I have not tested these ones):


h ttps://www.raywenderlich.com/146414/metal-tutorial-swift-3-part-1-getting-started

I don't know of any specific tutorials, sorry. I tend to wander through Apple's documentation and sample code.


OpenGL should be fine for a task like this, if you have experience with it. If you don't, then IMO you may as well invest your effort in the Metal learning curve instead.

NSBitmapImage vs CGImageRef
 
 
Q