Xlib 的 StretchBlt?
我正在寻找一个与 Xlib 的 GDI StretchBlt 执行相同操作的函数。我在 XLib 标头中找不到任何此类函数,因此我开始认为我必须了解 StretchBlt 如何为 XLib 自己实现它。我很感激任何帮助。
I'm looking for a function that does the same thing as GDI's StretchBlt for Xlib. I can't find any such function in the XLib headers so I am beginning to think I will have to understand how StretchBlt works to implement it myself for XLib. I appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Xlib 或 X 协议中没有任何东西可以做到这一点。一些方法可以包括:
最好的方法在很大程度上取决于项目的细节。一般来说,按照现代标准,Xlib 的绘图基元几乎毫无价值,因此您确实应该使用一些更高层的库。 Cairo 可能是默认选择,它广泛用于开源领域。
以通用且正确的方式为 Xlib 自己编写代码非常困难...问题是您必须处理用户可能拥有的任何视觉和色彩图。如果您知道用户将使用的确切硬件和软件,这可能是一件小事,否则可能会让人头疼。在 16 位、24 位和 32 位深度以及不同的字节序等之间需要进行大量转换。 GTK+ 和 Cairo 都有转换代码,因此如果您可以使用它们,您可以以固定格式(例如 ARGB32)编写拉伸例程,而不必处理所有其他格式。
There is nothing that does this in Xlib or the X protocol. Some ways to do it could include:
The best approach depends a lot on the details of your project. In general, Xlib's drawing primitives are nearly worthless by modern standards, so you really should get some higher layer library involved. Cairo is probably the default choice, it's widely-used in open source stuff.
Coding this yourself in a general and correct way for Xlib is pretty hard... the issue is that you have to deal with any visual and colormap your users might have. If you know the exact hardware and software your users will use, this may be a minor thing, otherwise it may be kind of a major headache. There are a lot of conversions to write between 16-bit and 24-bit and 32-bit depths and different endianness and whatever. GTK+ and Cairo have conversion code in there, so if you can use them you can write a stretch routine in a fixed format such as ARGB32, and not have to deal with all the others.
这种功能由 XRender 扩展提供:
http://cgit.freedesktop.org/xorg/proto/renderproto/plain /renderproto.txt
This kind of functionality is offered by the XRender extension:
http://cgit.freedesktop.org/xorg/proto/renderproto/plain/renderproto.txt