Jamey McElveen
Jamey McElveen

Reputation: 18305

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

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.

Upvotes: 5

Views: 4157

Answers (4)

Havoc Pennington
Havoc Pennington

Reputation:

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.

Upvotes: 2

codelogic
codelogic

Reputation: 73622

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.

Upvotes: 2

joshperry
joshperry

Reputation: 42227

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.

Upvotes: 0

Mehrdad Afshari
Mehrdad Afshari

Reputation: 421988

Why don't you use OpenGL views?

Upvotes: 2

Related Questions