Mac OS Cocoa: Draw a simple pixel on a canvas

后端 未结 8 803
悲哀的现实
悲哀的现实 2021-02-02 01:21

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

8条回答
  •  没有蜡笔的小新
    2021-02-02 01:27

    For drawing pixels as you describe, there's no need to create a path or resort to the Quartz 2D or OpenGL API.

    See NSRectFill() and related functions like NSRectFillList() and NSRectFillUsingOperation().

    If you're drawing a lot of individual pixels, NSRectFillList() is about as fast as you can do it without resorting to rolling your own image buffers.

提交回复
热议问题