SkSurfaceの使い方がずっとわからなかった。SkSurfaces::Rasterでインスタンスを作成できる。
void Test() { // #include "skia/include/core/SkSurface.h" SkImageInfo imginfo = SkImageInfo::Make(400, 400, kBGRA_8888_SkColorType, kOpaque_SkAlphaType); sk_sp<SkSurface> surface = SkSurfaces::Raster(imginfo); SkCanvas* canvas = surface->getCanvas(); // 図形の描画 SkPaint paint; paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(5); paint.setColor(SK_ColorBLUE); canvas->clear(SK_ColorWHITE); canvas->drawCircle(200, 200, 100, paint); // PNG出力 SkPixmap pixmap; if (surface->peekPixels(&pixmap)) { SkFILEWStream stream("test_sksurface.png"); SkPngEncoder::Options options; options.fZLibLevel = 9; SkPngEncoder::Encode(&stream, pixmap, options); } }