Introduction to two 2D graphics Libraries

Source: Internet
Author: User
Tags cairo


The latest project needs to find a cross-platform 2D graphics library. It is best to use interfaces compatible with Microsoft's GDI +. After some searches and comparisons, I summarized some information about this and put it here to take a note.

First, let's introduce the Cairo library. It doesn't matter if you haven't heard of it. Have you heard of Firefox ?! The render engine of Firefox uses this library. Cairo is a cross-platform 2D graphics library that supports many advanced features of GDI +, such as anti-alias and matrix transformation. However, it is said that
Cairo's efficiency is not very good and there is a certain gap with other libraries.

The best thing to use Cairo is that there is a libgdiplus library that works with it. This library encapsulates Cairo and provides an interface compatible with the GDI + flat API, in this way, we can port the GDI + code on the Windows platform to Unix or
Mac provides a shortcut.

The following describes the middleware (Anti-grain geometry). This library looks very efficient and can be used in its demo.
Show the page to see, the small examples inside are very cool!

Runtime also has an encapsulation similar to libgdiplus, called aggplus. But what is lacking in the US is that aggplus's encapsulation of the GDI + interface only achieves 20% at best, basically there is no practical value, but it is more convenient to compare the performance with the GDI +. In fact
There is such a performance test program in the download package. In some basic graphics render tests, compaction is more than 10 times faster than GDI +!

Cairo and NLP are both very good 2D graphics libraries. Although I have never been able to perform performance tests between Cairo and NLP, they seem to have better performance than Cairo. In terms of features, they seem to be the same, almost all the feature in GDI + 1.0 can find their counterparts in these two libraries. In terms of interfaces, Cairo + libgdiplus is a golden partner, as long as you are familiar with the flat interface of GDI +, cairo can be added to your project soon. The interfaces of pipeline are quite different and fully based on C ++ template.
Writing is basically the kind of thing that I still feel dizzy when I read the document. Some people say that if I want to use the idea, I should have a good knowledge of graphics!

In terms of cross-platform and compilation, the platform won the championship. It is easy to use it on Windows, UNIX, and Mac platforms, and Cairo is a little worse, it must be modified on the Windows platform (you must be familiar with it before modification ). Compiling libgdiplus in Windows seems to be an impossible task. At least I took some time and gave up this idea.

When I explained to my colleagues the most significant difference between Cairo + libgdiplus and SAIC, I made an analogy: the former is like a fully-equipped, ready-to-use car, the latter is like a pile of exquisite imported car accessories. It is relatively easy to use the former, but it may have a moderate performance. It takes a lot of time to use the latter, but it also requires professional knowledge, but once it starts up, it will be great!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.