Cairo with Windows graphics interface

Source: Internet
Author: User
Tags cairo gtk vector graphics library

1. Introduction

Two of Linux's most popular desktop environments are KDE and GNOME, and the underlying components of QT and gtk+,gtk+ are mapped using Cairo. Cairo (HTTP// cairographics.org) is the open source vector graphics library support a variety of output, Cairo by the C language to write a modular design is excellent, here to share (non-tutorial) Cairo of the Windows Transplant Customization (VS2012 compilation), and the graphics interface with Windows Dxgi docking, through Dxgi to render Displays the image frames produced by the Cairo.

2. Cairo Graphics Library

Cairo is a small project, how many lines did not go to statistics, cairo-1.12.18 source package 65.9M, the removal of test files, test code, documentation, its source code files near 10M. The transplant is of course from the Readme, the document says with Cygwin or msys compile, oneself with vs of course also can.

    • Create Cairo-features.h in CAIRO/SRC to describe the function modules of Cairo. This is a large custom version, image, FT (FreeType) is a must, PNG convenient to view images, SVG, PDF is widely used vector graphics format, XML, recording is my temporary use of the

  

    • To create a Cairo vs Win32 dll Empty project, Src\makefile.sources has a list of code files, the organization structure of the Code, and add code according to the module that the file is configured with. In addition, there are some dependent libraries Pixman, zlib, libpng, FreeType, which libpng also rely on zlib. These libraries are available in the latest version, and creating a VS project is mostly about the official document description

  

    • Compile build DLL, compile Cairo has more than 1000 warnings, the last generated DLL file Debug version 2.9m,release version 1.3M. Other dependent libraries of course have to be compiled in advance, Zlib is compiled for Dll,pixman, libpng, freetype all use static libraries. After compiling the DLL, you can use Cairo to draw the image in a memory that can be accessed.

  

3. Windows Graphics interface

The above two images are from Microsoft's official documentation, the Windows XP graphics system interface on the left, and Vista on the right and behind Windows. Starting with Vista, Microsoft has designed a new display driver model that adjusts the graphics system architecture to provide better image quality and provides hardware acceleration for the interface. Reference Document: https://msdn.microsoft.com/en-us/library/ee417756 (v=vs.85). aspx

Is Dxgi (DirectX Graphics Infrastructure), a new subsystem that starts with Vista. Dxgi is used to handle some underlying tasks such as enumerating hardware devices, creating a cache interaction Chain (Swap-chain), rendering a rendered image frame to an output device, and so on, and the program can directly access the DXGI. Reference Document: https://msdn.microsoft.com/en-us/library/bb205075 (v=vs.85). aspx

4. Display the Cairo image frame

Displaying an image in memory method can be done via GDI or D3D/OPENGL texture, but it is a quick way to write the image data to the display frame buffer. I have written a program that writes the in-memory image data to buffer. Read the Official Programming Guide and Reference, document located in the (MSDN Chapter) Desktop App Technologies-----> Graphics and Gaming-----> Direct 2D /Direct 3d/directx Graphics Articles

Cairo creates surface with its pixel format cairo_format_rgb24 is 32-bit, for the buffer pixel format dxgi_format_b8g8r8a8_unorm. Desc. The OutputWindow is the associated Output window. Cairo after the drawing is finished calling Cairo_image_surface_get_data to get the image data, I simply encapsulate a function to write the data to buffer.

Here is the drawing code and the resulting image

5. Concluding remarks

With. NET, a Web UI-based hybrid app framework with a complete suite of QT-like solutions, it is estimated that very few people use professional graphics libraries to create UI interfaces. This library can be used in some highly efficient mapping scenarios like the Windows 8 Task Manager performance interface. It is said that the next generation of human-computer interaction is voice and even vision, when users speak to the machine, or through machine vision (OpenCV) analysis of the user input, then the UI will become very simple and efficient, like Iron Man, left the war, and so on sci-fi blockbusters, no button, ScrollBar, Do not need touch, just to quickly draw and render, timely information to the user, I believe this is the development trend of human-computer interaction.

Cairo with Windows graphics interface

Related Article

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: info-contact@alibabacloud.com 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.