开发者

Drawing in Objective-c (iOS)

I develop an iOS app with user-drawing as one of its parts. I want to draw over a bitmap's context. This can be implemented in two ways:

1) When drawing option is selected I create bitmap context. The context is closed only when the tool is deactivated. So it remains opened during drawing.

2) Each time when user draws a line - I creat开发者_StackOverflowe new bitmap context, copy current drawing there (stored as image), add new lines and then close the context (and save new image, of course). So it remains opened during only concrete drawing operation.

The first method needs bitmap context to be opened for a (potentially) long time, the second - repeats image (with current drawing) copying each time and spends resources for frequent context creating / releasing. Which way is better? Why?


1, without any hesitation. Bitmap blending is very, very expensive in terms of CPU usage, you definitely want to avoid this.

Now, if you're into drawing, I would recommend giving OpenGL|ES a shot. Apple even provides a nice GLPaint example. You could achieve very impressive things using GLES 2 shaders. But that might get out of the scope of your question though :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜