Chinaunix首页 | 论坛 | 博客
  • 博客访问: 466954
  • 博文数量: 89
  • 博客积分: 1126
  • 博客等级: 少尉
  • 技术积分: 1432
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-11 23:37
文章分类

全部博文(89)

文章存档

2016年(6)

2015年(2)

2014年(1)

2013年(3)

2012年(23)

2011年(54)

分类: LINUX

2011-04-12 12:48:09

桌面环境:vmware虚拟机ubuntu10.10

root@ubuntu10:/work# uname -a
Linux ubuntu10 2.6.35-27-generic #48-Ubuntu SMP Tue Feb 22 20:25:29 UTC 2011 i686 GNU/Linux

root@ubuntu10:/work# date
2011年 04月 09日 星期六 20:36:32 CST
下载SKIA源码:
root@ubuntu10:/work/skia-read-only# svn info 
路径: .
URL:
版本库根:
版本库 UUID: 2bbb7eff-a529-9590-31e7-b0007b416f81
版本: 1083
节点种类: 目录
调度: 正常
最后修改的作者: mike@reedtribe.org
最后修改的版本: 1083
最后修改的时间: 2011-04-08 10:41:54 +0800 (五, 2011-04-08)

下载下来以后,编译不过,缺少头文件。依次安装jpeg,png,libz,freetype,gif库。安装时执行命令:.configure;make ;make install。
然后make.oK

写测试程序:
root@ubuntu10:/work/skia-read-only/wanghuan# cat main.cpp -n
     1
    15
    20
    21
    22 #include "SkBitmap.h"
    23 #include "SkDevice.h"
    24 #include "SkPaint.h"
    25 #include "SkRect.h"
    26 #include "SkImageEncoder.h"
    27 int main()
    28 {
    29        // Declare a raster bitmap, which has an integer width and height,
    30        // and a format (config), and a pointer to the actual pixels.
    31        // Bitmaps can be drawn into a SkCanvas, but they are also used to
    32        // specify the target of a SkCanvas' drawing operations.
    33        SkBitmap bitmap;
    34        bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
    35        bitmap.allocPixels();
    36 bitmap.eraseColor(0);
    37
    38        // A Canvas encapsulates all of the state about drawing into a
    39        // device (bitmap).  This includes a reference to the device itself,
    40        // and a stack of matrix/clip values. For any given draw call (e.g.
    41        // drawRect), the geometry of the object being drawn is transformed
    42        // by the concatenation of all the matrices in the stack. The
    43        // transformed geometry is clipped by the intersection of all of the
    44 // clips in the stack.
    45 SkCanvas canvas(bitmap);
    46
    47        // SkPaint class holds the style and color information about how to
    48        // draw geometries, text and bitmaps.
    49        SkPaint paint;
    50        // SkIRect holds four 32 bit integer coordinates for a rectangle.
    51        SkRect r;
    52        paint.setARGB(255, 255, 0, 0);
    53        r.set(25, 25, 145, 145);
    54        canvas.drawRect(r, paint);
    58        paint.setARGB(255, 0, 255, 0);
    59        r.offset(20, 20);
    60        canvas.drawRect(r, paint);
    61        paint.setARGB(255, 0, 0, 255);
    62        r.offset(20, 20);
    63        canvas.drawRect(r, paint);
    64        // SkImageEncoder is the base class for encoding compressed images
    65        // from a specific SkBitmap.
    66        SkImageEncoder::EncodeFile("snapshot.png", bitmap,
    67                SkImageEncoder::kPNG_Type,
    68                 100);
    69        return 0;
    70 }
这里使用了unix-test-app目录的Makefile修改:
root@ubuntu10:/work/skia-read-only/wanghuan# cat Makefile  -n
     1 # Build the unix test app
     2 C_INCLUDES := -I../include/core \
     3              -I../include/config \
     4              -I../include/effects \
     5              -I../include/images \
     6              -I../include/utils \
     7              -I../include/views \
     8              -I../include/xml \
     9              -I../include/gpu \
    10              -I../gpu/include \
    11              -I../include/utils/unix \
    12              -I../samplecode
    13
    14 VPATH = libs:../src/ports:../samplecode:../src/core:../src/utils/unix
    15
    16 #generate debugging info
    17 CFLAGS = -g
    18
    19 SRC_LIST := main.cpp 
    20
    21 test-skia: $(SRC_LIST) ../out/libskia.a -lpthread -lz -lfreetype  -lpng
    22 g++ $(C_INCLUDES) $(CFLAGS) $^ -o $@
    23
    24 clean:
    25 #rm -rf ../out # Copied from ../Makefile
    26 #rm -rf out
阅读(1388) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~