What is the fastest way to draw single pixels directly to the screen in an iPhone application?

后端 未结 4 1584
后悔当初
后悔当初 2021-01-03 04:21

I am looking the fastest way to draw thousands of individually calculated pixels directly to the screen in an iPhone application that preforms extremely well.

相关标签:
4条回答
  • 2021-01-03 04:42

    In all graphics frameworks I've ever used, the way you'd do this is to write your pixels into a block of memory (in ARGB or RGBA format for example), and then push the whole block of memory to the graphics subsystem. No "draw one point" API can possibly be fast, if you want to draw thousands of pixels quickly you need to push an image/texture/bitmap/whatever-you-want-to-call-it, rather than pushing individual points one at a time.

    0 讨论(0)
  • Why don't you use OpenGL views?

    0 讨论(0)
  • 2021-01-03 04:48

    I would create a BMP the size of the view, add it to the view and draw into the BMP. Cocoa doesn't have any way to draw a single pixel to a view, other than faking it by using a line with a length of 1 pixel like this Question mentions.

    0 讨论(0)
  • 2021-01-03 04:53

    Most probably using OpenGL, something like:

    glBegin(GL_POINTS);
    glColor3f(...);
    glVertex3f(...);
    ...
    glEnd();
    

    Even faster would probably be to use vertex arrays for specifying the points.

    0 讨论(0)
提交回复
热议问题