Ejemplo n.º 1
0
static void handle_proc(const GBitmap& bitmap, void (*proc)(const GBitmap&),
                        const std::string& root, const char name[]) {
    std::string path(root);
    path += name;
    path += ".png";

    // fill the bitmap with transparent black
    memset(bitmap.pixels(), 0, bitmap.rowBytes() * bitmap.height());
    proc(bitmap);

    if (!bitmap.writeToFile(path.c_str())) {
        fprintf(stderr, "failed to write %s\n", path.c_str());
    }
}
Ejemplo n.º 2
0
static void handle_proc(const DrawRec& rec, const char path[], const MatrixRec& mrec) {
    GBitmap bitmap;
    setup_bitmap(&bitmap, rec.fWidth, rec.fHeight);

    GCanvas* canvas = GCanvas::Create(bitmap);
    if (NULL == canvas) {
        fprintf(stderr, "failed to create canvas for [%d %d] %s\n",
                rec.fWidth, rec.fHeight, rec.fName);
        return;
    }

    canvas->setCTM(mrec.fMatrix(rec.fWidth, rec.fHeight));
    rec.fDraw(canvas);

    if (!bitmap.writeToFile(path)) {
        fprintf(stderr, "failed to write %s\n", path);
    }

    delete canvas;
    free(bitmap.fPixels);
}