static inline wbExport_t wbExport_open(const char *file, const char *type0) { wbExport_t exprt; wbExportKind_t kind; char *type; type = wbString_toLower(type0); if (wbString_sameQ(type, "cvs")) { kind = wbExportKind_csv; } else if (wbString_sameQ(type, "tsv")) { kind = wbExportKind_tsv; } else if (wbString_sameQ(type, "raw") || wbString_sameQ(type, "dat")) { kind = wbExportKind_raw; } else if (wbString_sameQ(type, "ppm")) { kind = wbExportKind_ppm; } else { wbLog(ERROR, "Invalid export type ", type0); wbExit(); } exprt = wbExport_open(file, kind); wbDelete(type); return exprt; }
void wbExport(const char *file, wbExportKind_t kind, void *data, int rows, int columns, wbType_t type) { wbExport_t exprt; if (file == nullptr) { return; } exprt = wbExport_open(file, kind); wbExport_write(exprt, data, rows, columns, type); wbExport_close(exprt); }
void wbExport(const char *file, wbReal_t *data, int rows, int columns) { wbExportKind_t kind; wbExport_t exprt; if (file == NULL) { return; } kind = _parseExportExtension(file); exprt = wbExport_open(file, kind); wbExport_write(exprt, data, rows, columns, wbType_real); wbExport_close(exprt); }
void wbExport(const char *file, unsigned char *data, int rows, int columns) { wbExportKind_t kind; wbExport_t exprt; if (file == nullptr) { return; } kind = _parseExportExtension(file); exprt = wbExport_open(file, kind); wbExport_write(exprt, data, rows, columns, wbType_ubit8); wbExport_close(exprt); }
void wbExport(const char *file, wbImage_t img) { wbExportKind_t kind; wbExport_t exprt; if (file == NULL) { return; } kind = _parseExportExtension(file); exprt = wbExport_open(file, kind); wbAssert(kind == wbExportKind_ppm); wbExport_writeAsImage(exprt, img); wbExport_close(exprt); }