Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1124360
  • 博文数量: 241
  • 博客积分: 4385
  • 博客等级: 上校
  • 技术积分: 2383
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-07 23:13
文章分类

全部博文(241)

文章存档

2013年(1)

2012年(8)

2011年(62)

2010年(109)

2009年(61)

分类: LINUX

2011-08-29 10:53:53

1: what is cario?

see details in 

2: build cario dev environment

(1)download pixman-0.22.2 and cairo-1.10.2

(2)install cario and pixman dependency

  1. sudo apt-get install libpng12-dev libz-dev libxrender-dev libfontconfig1-dev
(3)install pixman

  1. cd pixman-0.22.2/
  2. ./configure
  3. make
  4. sudo make install

(4)install cario

  1. cd cairo-1.10.2/
  2. ./configure
  3. make
  4. sudo make install
3: CLI dev

  1. gcc -o hello -I/usr/local/include/cairo -I/usr/local/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -L/usr/local/lib -lcairo hello.c
or use shortcut command

  1. gcc -o hello $(pkg-config --cflags --libs cairo) hello.c
4: GUI dev

(1) build eclipse + cdt (google for details)

(2) new c project, set project properties as,  then run project



5: hello.c code

  1. #include <cairo.h>

  2. int main (int argc, char *argv[])
  3. {
  4.         cairo_surface_t *surface =
  5.                 cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
  6.         cairo_t *cr =
  7.                 cairo_create (surface);

  8.         cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
  9.         cairo_set_font_size (cr, 32.0);
  10.         cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
  11.         cairo_move_to (cr, 10.0, 50.0);
  12.         cairo_show_text (cr, "Hello, world");

  13.         cairo_destroy (cr);
  14.         cairo_surface_write_to_png (surface, "hello.png");
  15.         cairo_surface_destroy (surface);
  16.         return 0;
  17. }
阅读(3356) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~