Пример #1
0
int main(int argc, char** argv) {
    const char* pathRoot = "";
    const char* match = NULL;

    for (int i = 1; i < argc; ++i) {
        if (0 == strcmp(argv[i], "--write") && i+1 < argc) {
            pathRoot = argv[++i];
        } else if (0 == strcmp(argv[i], "--match") && i+1 < argc) {
            match = argv[++i];
        }
    }

    std::string root(pathRoot);
    if (root.size() > 0 && root[root.size() - 1] != '/') {
        root += "/";
    }

    for (int j = 0; j < GARRAY_COUNT(gMatrixRec); ++j) {
        for (int i = 0; i < GARRAY_COUNT(gRec); ++i) {
            std::string path(pathRoot);
            path += gRec[i].fName;
            path += gMatrixRec[j].fSuffix;
            path += ".png";

            if (match && !strstr(path.c_str(), match)) {
                continue;
            }
            handle_proc(gRec[i], path.c_str(), gMatrixRec[j]);
        }
    }
    return 0;
}
Пример #2
0
int main(int argc, char** argv) {
    int N = 256;
    std::string root;

    for (int i = 1; i < argc; ++i) {
        if (0 == strcmp(argv[i], "--size") && i+1 < argc) {
            N = atoi(argv[++i]);
        }
        if (0 == strcmp(argv[i], "--write") && i+1 < argc) {
            root = argv[++i];
        }
        
    }
    if (N < 1 || N > 1024) {
        fprintf(stderr, "specify a reasonable size for the image (e.g. 256)\n");
        return -1;
    }

    if (root.size() > 0 && root[root.size() - 1] != '/') {
        root += "/";
        if (!mk_dir(root.c_str())) {
            return -1;
        }
    }
    
    GBitmap bitmap;
    bitmap.fWidth = N;
    bitmap.fHeight = N;
    bitmap.fRowBytes = N * sizeof(GPixel);
    bitmap.fPixels = (GPixel*)malloc(bitmap.rowBytes() * bitmap.height());

    for (int i = 0; i < GARRAY_COUNT(gRec); ++i) {
        handle_proc(bitmap, gRec[i].fProc, root, gRec[i].fName);
    }
    
    free(bitmap.fPixels);
    return 0;
}