glitz

홈페이지: http://www.freedesktop.org/wiki/Software/glitz

glitz 라이브러리를 이용하면 opengl 하드웨어 가속 그래픽을 지원하여, 현대적인 3D 디스플레이 하드웨어의 능력을 이용할 수 있다.
cairo에서 glitz 백 엔드를 지원하므로, 더욱 빠른 처리를 할 수 있다.

Glitz is a software library for 2D graphics which provides hardware acceleration using OpenGL, an API for 3D graphics.

다운로드: 0.5.6

ClutterCairo

홈페이지: http://www.clutter-project.org/sources/clutter-cairo/

An experimental clutter cairo ‘drawable’ actor. Sucks a bit as renders
cairo via an image surface and thus no real cairo rendering
acceleration. Experiments with glitz and sharing GL contexts for such
acceleration proved problematic. Needs more investigation.

bubbles

다운로드: 0.8.2

librsvg

홈페이지: http://librsvg.sourceforge.net/

벡터 그래픽 포맷 SVG를 취급하는 라이브러리.

In simple terms, librsvg is a component used within software applications to enable support for SVG-format scalable graphics. In contrast to raster formats, scalable vector graphics provide users and artists a way to create, view, and provide imagery that is not limited to the pixel or dot density that an output device is capable of.
Many software developers use the librsvg library to render SVG graphics. It is lightweight and portable, requiring only libxml and libart at a minimum, while providing extra features when used with libcroco, libgsf, and mozilla. It is included as part of the GNOME Desktop, and is licensed under the LGPL license.

다운로드: 2.26.0

cairo & cairomm example

아래의 코드들은 wxWidgets와의 조합이며, wxEVT_PAINT 이벤트내에서 작성하면 될것이다. MinGW로 테스트 되었다.

아래의 코드는 cairo의 경우이다.

wxPaintDC dc(this);

wxRect rect = GetClientRect();

if(rect.width == 0 || rect.height == 0) return;

// RENDER_NATIVE
HWND hWnd = (HWND)this->GetHandle();
HDC hDC = ::GetDC(hWnd);

HDC hMemDC = CreateCompatibleDC(hDC);
HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.width, rect.height);
SelectObject(hMemDC, hBitmap); 

cairo_surface_t* surface = cairo_win32_surface_create(hMemDC);
cairo_t* image = cairo_create(surface);

cairo_pattern_t *pat;

pat = cairo_pattern_create_linear (0.0, 0.0,  0.0, 256.0);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
cairo_rectangle (image, 0, 0, rect.width, rect.height);
cairo_set_source (image, pat);
cairo_fill (image);
cairo_pattern_destroy (pat);

pat = cairo_pattern_create_radial (115.2, 102.4, 25.6,
							   102.4,  102.4, 128.0);
cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
cairo_set_source (image, pat);
cairo_arc (image, 128.0, 128.0, 76.8, 0, 2 * M_PI);
cairo_fill (image);
cairo_pattern_destroy (pat);

BitBlt(hDC, 0, 0, rect.width, rect.height, hMemDC, 0, 0, SRCCOPY);

DeleteDC(hMemDC);
DeleteObject(hBitmap);

// Because we called ::GetDC make sure we relase the handle
// back to the system or we'll have a memory leak.
::ReleaseDC(hWnd, hDC);

아래의 코드는 cairomm의 경우이다.

wxPaintDC dc(this);

wxRect rect = GetClientRect();

if(rect.width == 0 || rect.height == 0) return;

// RENDER_NATIVE
HWND hWnd = (HWND)this->GetHandle();
HDC hDC = ::GetDC(hWnd);

HDC hMemDC = CreateCompatibleDC(hDC);
HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.width, rect.height);
SelectObject(hMemDC, hBitmap); 

Cairo::RefPtr<Context> context;
Cairo::RefPtr<Win32Surface> surface;

surface = Win32Surface::create(hMemDC);
context = Context::create(surface);

// draw background
Cairo::RefPtr<Cairo::LinearGradient> background_gradient_ptr = 
	Cairo::LinearGradient::create (0, 0, rect.width, rect.height);

background_gradient_ptr->add_color_stop_rgb (0, 0.7,0,0);
background_gradient_ptr->add_color_stop_rgb (1, 0.3,0,0);

// Draw a rectangle and fill with gradient
context->set_source (background_gradient_ptr);
context->rectangle (0, 0, rect.width, rect.height);
context->fill();

surface->finish();

BitBlt(hDC, 0, 0, rect.width, rect.height, hMemDC, 0, 0, SRCCOPY);

DeleteDC(hMemDC);
DeleteObject(hBitmap);

// Because we called ::GetDC make sure we relase the handle
// back to the system or we'll have a memory leak.
::ReleaseDC(hWnd, hDC);

wxCairo

cairo라는 오픈소스 백터 그래픽 라이브러리가 있다.

http://www.cairographics.org/

wxCairo는 cairo를 wxWidgets의 프레임에 붙여서 사용할수 있는 예제를 제공하는 프로젝트이다.
라이브러리가 아니라 예제를 제공한다.
즉 간단히 말하자면 dc 를 얻어와 맵핑시켜준후 사용할 수 있는 예제를 제공한다.

다운로드는 svn에서.

# Non-members may check out a read-only working copy anonymously over HTTP.
svn checkout http://wxcairo.googlecode.com/svn/trunk/ wxcairo-read-only

아래는 제공하는 예제를 mingw에서 컴파일해본 화면이다.

cairo를 이용한 고품질의 그래프 위젯을 생각해볼만도 하다.
python용으로 개발된 Cairo Plot 이라는 프로젝트가 있는데.. 상당히 괜찮아보인다.

스샷은 여기서.

wxWidgets버전으로 포팅해볼까나..

cairo

홈페이지: http://cairographics.org/

크로스 플랫폼 오픈 소스 벡터 그래픽 라이브러리

cairo-banner

Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System, Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL (through glitz), XCB, BeOS, OS/2, and DirectFB.

Cairo is designed to produce consistent output on all output media while taking advantage of display hardware acceleration when available (eg. through the X Render Extension).

The cairo API provides operations similar to the drawing operators of PostScript and PDF. Operations in cairo including stroking and filling cubic Bézier splines, transforming and compositing translucent images, and antialiased text rendering. All drawing operations can be transformed by any affine transformation (scale, rotation, shear, etc.)

Cairo is implemented as a library written in the C programming language, but bindings are available for several different programming languages.

Cairo is free software and is available to be redistributed and/or modified under the terms of either the GNU Lesser General Public License (LGPL) version 2.1 or the Mozilla Public License (MPL) version 1.1 at your option.

다운로드: 1.8.8, 1.9.4, 1.10.2