开发者

ios, quartz2d, fastest way of drawing bitmap context into window context?

ios, quartz2d, fastest way of drawing bitmap context into window context?

hallo, sorry for my weak english,

I am looking hardly for fastest possible way of redrawing bitmap context (which holds pointer to may raw bitmap data) onto iphone view window context

in the examples i have found in the net people are doing this by making CGImage from such bitmap context then making UIImage from this and drawing it onto the view

i am thinking if it is a fastest way of doing it? do i need to create then release CGImage - in documentation there is info that making CGImage copy data - is it possible to send my bitmap context data straight to window context without allocating/ copying then releasing it in CGImage? (wh开发者_开发问答ich seem physically not necessary)

parade


Well, i have done some measuring and here is what i have got -

no need to worry about creating CGImage and UIImage stuff becouse it all only takes about 2 miliseconds - my own image processing routines takes the most time (about 100 ms) drawing UIImage at point takes 20 ms - and there is also third thing: when i receive image buffer in my video frame ready delegate i call setNeedsDisplay by performSelectorOnMainThread - and this operation takes sometimes 2 miliseconds and sometimes about 40 miliseconds - does anybody know what it is with that - can i speed up this thing? thanx in advance

parade


I think I see what you are getting at. You have a pointer to the bitmap data and you just want the window to display that. On the old Mac OS (9 and previous) you could write draw directly to video memory, but you can't do that anymore. Back then video memory was part of RAM and now it's all on the OpenGL card.

At some level the bitmap data will have to be copied at least once. You can either do it directly by creating an OpenGL texture from the data and drawing that in an OpenGL context or you can use the UIImage approach. The UIImage approach will be slower and may contain two or more copies of the bitmap data, once to the UIImage and once when rendering the UIImage.

In either case, you need to create and release the CGImage.


The copy is necessary. You first have to get the bitmap into the GPU, as only the GPU has access to compositing any layer to the display window. And the GPU has to make a copy into it's opaque (device dependent) format. One way to do this is to create an image from your bitmap context (other alternatives include uploading an OpenGL texture, etc.)

Once you create an image you can draw it, or assign it to a visible CALayer's contents. The latter may be faster.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜