在哪里可以找到用于直接写入框架的简单图形 C 库?

发布于 2024-07-14 03:25:24 字数 1542 浏览 8 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

流年里的时光 2024-07-21 03:25:24

对于非常简单的需求(直线、圆形、多边形、文本),我总是自己制作。 查看 Bresenham 的直线和圆算法,Wu 的对圆和直线抗锯齿的修改。

Gimp 将为图像输出 C 代码,这就是我为字体所做的,并且绘制它们非常容易。 我已经使用了抗锯齿(gimp --> 灰度,使用灰度值作为 alpha),但没有做过比例字体。 它们并不难,并且可以使显示效果更好一些,但我还不需要它们。

多边形只是多条线,填充多边形实现起来非常有趣

这并不是很多工作,你会从经验中成长。

但是,如果您决定要渲染 SVG 或其他一些复杂的矢量语言,那么就需要使用库了。 但对于简单的事情来说,这并不复杂。

-亚当

For very simple needs (lines, circles, polygons, text) I have always just made my own. Check out bresenham's algorithm for lines and circles, Wu's modifications for antialiasing on circles and lines.

Gimp will output C code for images, which is what I do for fonts, and drawing them is pretty easy. I have used anti-aliasing (gimp --> grayscale, use the grayscale value as the alpha), but haven't done proportional fonts. They aren't much harder, and can make the display a bit nicer, but I haven't needed them yet.

Polygons are simply multiple lines, and filled polygons are quite fun to implement.

It's not a lot of work, and you'll grow from the experience.

If, however, you decide you want to render SVG or some other complex vector language, then a library is in order. But for simple things, this isn't complex.

-Adam

唠甜嗑 2024-07-21 03:25:24

我想选择第二个 OpenGL,尤其是 OpenGL|ES 变体。

以下是基于软件的 OpenGL 渲染器的链接: http://sourceforge.net/projects/ogl-es 但是

过去三年我一直在 ARM9 和类似处理器上编写商业软件光栅化代码,所以我想我可以评论 cairo 和其他高级 API 的使用:

它们工作得很好并且非常强大, 对于像 ARM9 这样有限的目标,您永远不会对其性能感到满意。 图形库是根据典型的台式电脑编写的,它们以精度换取性能。 这对于高质量 SVG 渲染来说很好,但在简陋的 ARM 上会很慢。

我上面建议的 Vincent OpenGL|ES 有一个用于 ARM-CPU 的即时动态代码生成引擎,因此您几乎可以获得手动优化的性能汇编代码。

如果您可以将自己限制为仅一种位图格式、两种混合模式和大量渲染基元,那么您可以通过自己编写十几个渲染例程来获得更好的性能。 不过,根据您的经验和要求,可能需要两天到一个月的时间。

I'd like to second OpenGL, especially the OpenGL|ES variant.

Here is a link to a Software based OpenGL-Renderer: http://sourceforge.net/projects/ogl-es

I've spend the last three years writing commercial software rasterization codes on ARM9 and similar processors, so I think I can comment on use of cairo and other high level APIs:

They work very well and are incredible powerfull, but on a target as limited as an ARM9 you will never be happy with the performance. The graphic libs are written with your typical Desktop PC in mind, and they trade precision for performance. This is nice for high quality SVG rendering, but to slow on a humble ARM.

The Vincent OpenGL|ES I've suggested above has a on the fly dynamic code generation engine for ARM-CPUs in place, so you get almost the performance of hand-optimized assembler code.

If you can limit yourself to just one bitmap-format, just two blend-modes and a hand full of rendering primitives you may get better performance by writing a dozen of render-routines yourself. Depending on your experience and requirements that can take anything from two days to a month though..

清醇 2024-07-21 03:25:24

Cairo 非常强大且易于使用。 我认为 Mozilla 使用它作为 元素和 SVG 渲染器的基础。

Cairo is pretty powerful and easy to use. I think Mozilla uses it as the basis for the <canvas> element and the SVG renderer.

烟沫凡尘 2024-07-21 03:25:24

从您的要求来看,您似乎需要诸如嵌入式帧缓冲区库(或任何名称)之类的东西。 几年前,我尝试过以下一些嵌入式浏览器(但没有进入市场)。 不幸的是,我不记得太多可以给你任何分析。 看一下:

  • DirectFB
  • GTK/X (或使用 directFB 的端口)
  • 开罗(正如另一位海报所建议的——这非常强大)

此外,这个 文章 可能会引起兴趣。

From your requirements it appears you need something like an embedded framebuffer library (or whatever it is called). I played around with some of the following a few years back for an embedded browser (which didn't make it to the market). Unfortunately, I can't remember much to give you any analysis. Have a look:

  • DirectFB
  • GTK/X (or a port using directFB)
  • Cairo (as another poster has suggested -- this is very powerful)

Also, this article may be of interest.

幸福%小乖 2024-07-21 03:25:24

尝试 SDL。 从网页:

Simple DirectMedia Layer 是一个跨平台多媒体库,旨在通过 OpenGL 提供对音频、键盘、鼠标、操纵杆、3D 硬件和 2D 视频帧缓冲区的低级访问。 MPEG 播放软件、模拟器和许多流行游戏都使用它,包括屡获殊荣的 Linux 移植版“文明:权力召唤”。

Try SDL. From the web page:

Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. It is used by MPEG playback software, emulators, and many popular games, including the award winning Linux port of "Civilization: Call To Power."

辞别 2024-07-21 03:25:24

OPenGL有一组2d函数,不确定它对你来说是否太臃肿或者是否可以修剪。 至少它是用 C 语言编写的。

OPenGL has a set of 2d functions, not sure if it is too bloated for you or if it can be trimmed down. It is written in C, at least.

弄潮 2024-07-21 03:25:24

我发现 Adafruit GFX 库很符合我的喜好。
非常非常简单和基本:
https://github.com/adafruit/Adafruit-GFX-Library

I found the Adafruit GFX library to my liking.
Very very simple and basic:
https://github.com/adafruit/Adafruit-GFX-Library

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文