ios,quartz2d,将位图上下文绘制到窗口上下文的最快方法?
ios,quartz2d,将位图上下文绘制到窗口上下文的最快方法?
你好,抱歉我的英语不好,
我正在寻找最快的重绘位图的方法 上下文(它保存指向原始位图数据的指针)到 iPhone 上 查看窗口上下文
在我在网上找到的示例中 人们正在这样做 从这样的位图上下文制作 CGImage 然后制作 UIImage 由此并将其绘制到视图上,
我在想这是否是最快的方法?我需要创建吗 然后发布 CGImage - 在文档中有信息 使 CGImage 复制数据 - 是否可以发送我的位图上下文 数据直接到窗口上下文,无需分配/复制 以CGImage形式发布? (这在物理上似乎没有必要)
游行
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? (which seem physically not necessary)
parade
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我已经做了一些测量,这就是我所得到的 -
无需担心创建 CGImage 和 UIImage 的东西,因为这一切只需要大约 2 毫秒 - 我自己的图像处理例程花费最多的时间(大约 100 毫秒)绘制 UIImage此时需要 20 毫秒 - 还有第三件事:当我在视频帧就绪委托中接收图像缓冲区时,我通过 PerformSelectorOnMainThread 调用 setNeedsDisplay - 这个操作有时需要 2 毫秒,有时大约 40 毫秒 - 有人知道它是什么吗那-我可以加快这件事吗?感谢提前
游行
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
我想我明白你的意思了。您有一个指向位图数据的指针,并且您只希望窗口显示它。在旧的 Mac OS(9 及更早版本)上,您可以将绘图直接写入视频内存,但您不能再这样做了。那时视频内存是 RAM 的一部分,现在它全部位于 OpenGL 卡上。
在某种程度上,位图数据必须至少复制一次。您可以通过从数据创建 OpenGL 纹理并在 OpenGL 上下文中绘制它来直接完成此操作,也可以使用 UIImage 方法。 UIImage 方法会比较慢,并且可能包含两个或多个位图数据副本,一次到 UIImage,一次在渲染 UIImage 时。
无论哪种情况,您都需要创建并释放 CGImage。
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.
副本是必要的。您首先必须将位图放入 GPU,因为只有 GPU 才能将任何图层合成到显示窗口。 GPU 必须将其复制为不透明(取决于设备)格式。一种方法是从位图上下文创建图像(其他替代方法包括上传 OpenGL 纹理等)。
创建图像后,您可以绘制它,或将其分配给可见的 CALayer 内容。后者可能更快。
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.