cairo 编译成功命令ubuntu, 但生成png图片没出效果,不知道为啥,先能编译吧

export PKG_CONFIG_PATH=/home2/hjliu/cairo/lib/:/home2/hjliu/cairo/lib/pixman/pixman


./configure --prefix=/home2/hjliu/cairo/ --host=mipsel-linux --with-x --disable-xlib --disable-xlib-xrender --disable-directfb  --disable-win32 --disable-pdf --disable-ps --disable-svg --enable-png --enable-freetype  LIBS='-L/home2/hjliu/cairo/lib/ -lz' CPPFLAGS='-I/home2/hjliu/cairo/lib/zlib/' png_CFLAGS='-I/home2/hjliu/cairo/lib/libpng/' FONTCONFIG_CFLAGS='-I/home2/hjliu/cairo/lib/fontconfig' FREETYPE_CFLAGS='-I/home2/hjliu/cairo/lib/freetype/freetype2/ -I/home2/hjliu/cairo/lib/freetype/include' pixman_CFLAGS='-I/home2/hjliu/cairo/lib/pixman/pixman'



g++ -o a.out test.cpp -I/home2/hjliu/cairo/src -L/home2/hjliu/cairo/sample/ -lcairo -lpixman-1 -lpng14


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home2/hjliu/cairo/sample/


export PKG_CONFIG_PATH=/home/nfs1/cairo/lib/all:/home/nfs1/cairo/lib/pixman/pixman


./configure --disable-xlib --disable-xlib-xrender --disable-directfb  --disable-win32 --disable-pdf --disable-ps --disable-svg --enable-png --enable-freetype  LIBS='-L/home/nfs1/cairo/lib/all -lz' CPPFLAGS='-I/home/nfs1/cairo/lib/zlib/' png_CFLAGS='-I/home/nfs1/cairo/lib/libpng/' FONTCONFIG_CFLAGS='-I/home/nfs1/cairo/lib/fontconfig' FREETYPE_CFLAGS='-I/home/nfs1/cairo/lib/freetype/freetype2/ -I/home/nfs1/cairo/lib/freetype/include' pixman_CFLAGS='-I/home/nfs1/cairo/lib/pixman/pixman'



g++ -o a.out test.cpp -I/home/nfs1/cairo/src -I/home/nfs1/cairo/lib/freetype/include -L/home/nfs1/cairo/lib/all -lfreetype -lexpat -lcairo -lpixman-1 -lpng14 -lfontconfig -lfreetype


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/nfs1/cairo/lib/all


sudo mount -t nfs -o nolock 192.168.80.110:/home2/hjliu /home/nfs1



#include  
#include
#include
#include
using namespace std;
int  
main11 (int argc, char *argv[])  
{  
    cairo_surface_t *surface;  
    cairo_t *cr;  
  
    int width = 100;  
    int height = 100;  
    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);  
    cr = cairo_create (surface);  
  
    /* Drawing code goes here */  
    cairo_set_line_width (cr, 10);  
    cairo_set_source_rgb (cr, 0xff, 0xff, 0);  
    cairo_rectangle (cr, width/4, height/4, width/2, height/2);  
    cairo_stroke (cr);  
  
    /* Write output and clean up */  
    cairo_surface_write_to_png (surface, "rectangle.png");  
    cairo_destroy (cr);  
    cairo_surface_destroy (surface);  
  
  
  
  
    return 0;  
}  






#include  


#define SIZE    (640)       /* 太极图大小 */  
#define CX  (SIZE / 2)  /* 太极圆中心横坐标 */  
#define CY  (SIZE / 2)  /* 太极圆中心纵坐标 */  
#define R   (SIZE / 2)  /* 太极圆半径 */  
  
/* 把角度转换为所对应的弧度 */  
#define ANGLE(ang)  (ang * 3.1415926 / 180.0)  
  
int main(int argc, char *argv[])  
{  
// FILE *file;
// file = fopen("a.png", "w");
    /* 创建32位RGBA颜色格式的Cairo绘图环境,直接在Memory中渲染 */  
    cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, SIZE + 1, SIZE + 1);  
if(surface == NULL)
{
printf("surf err");
}


    cairo_t* cr = cairo_create(surface);  
  if(cr == NULL)
{
printf("cr err");
}
    /* 绘制太极边框 */  
//cairo_set_target_png(cr, file, CAIRO_FORMAT_ARGB32, 400, 400);
    cairo_set_line_width(cr, 2.0);  
    cairo_set_source_rgba(cr, 0, 0, 0, 1);  
    cairo_arc(cr, CX, CY, R, ANGLE(0), ANGLE(360));  
    cairo_stroke(cr);  
  
  /* 绘制阴阳圆 */  
    cairo_set_source_rgba(cr, 0, 0, 0, 1);  
    cairo_arc(cr, CX, CY, R, ANGLE(90), ANGLE(270));  
    cairo_fill(cr);  
    cairo_set_source_rgba(cr, 1, 1, 1, 1);  
    cairo_arc(cr, CX, CY, R, ANGLE(-90), ANGLE(90));  
    cairo_fill(cr);  
  
    /* 绘制阴阳线 */  
    cairo_set_source_rgba(cr, 0, 0, 0, 1);  
    cairo_arc(cr, CX, CY - R / 2, R / 2, ANGLE(-90), ANGLE(90));  
    cairo_fill(cr);  
    cairo_set_source_rgba(cr, 1, 1, 1, 1);  
    cairo_arc(cr, CX, CY + R / 2, R / 2, ANGLE(90), ANGLE(270));  
    cairo_fill(cr);  
  
    /* 绘制太极眼 */  
    cairo_set_source_rgba(cr, 1, 1, 1, 1);  
    cairo_arc(cr, CX, CY - R / 2, R / 10, ANGLE(0), ANGLE(360));  
    cairo_fill(cr);  
    cairo_set_source_rgba(cr, 0, 0, 0, 1);  
    cairo_arc(cr, CX, CY + R / 2, R / 10, ANGLE(0), ANGLE(360));  
    cairo_fill(cr);  
  
    /* 将Memory的渲染效果存储到图片中 */  
    cairo_surface_write_to_png(surface, "a.png");  
    /* 销毁并退出Cairo绘图环境 */  
    cairo_destroy(cr);
    cairo_surface_destroy (surface);  
//fclose(file);
    return 0;  
}  
  
    

你可能感兴趣的:(其他)