// Example on how to use the library int main() { unsigned int width = 1024; unsigned int height = 768; unsigned int pages = 4; unsigned int pixel_bit_depth = 16; void* buffer; char* output_path = "output.tif"; char* artist = "Artist"; char* copyright = "Copyright"; char* make = "Camera Manufacturer"; char* model = "Camera Model"; char* software = "Software"; char* image_desc = "Created as a dynamic library"; // Uses global tiffWritePtr, which either points to tiffWrite from a // linked file or from a dynamic library. TRYFUNC(opendl(), "Could not use dynamic library.") TRYFUNC(calculateImageArrays(width, height, pages, pixel_bit_depth, &buffer), "Could not calclate buffer.") DEBUGP("Calculated buffer.") TRYFUNC((*tiffWritePtr) (width, height, pages, pixel_bit_depth, artist, copyright, make, model, software, image_desc, output_path, buffer), "Could not create tiff.") DEBUGP("Wrote TIFF.") TRYFUNC(closedl(), "Could not close dynamic library.") return 0; }
// Example on how to use the library int main(void) { unsigned int width = 1024; unsigned int height = 768; unsigned int pages = 7; unsigned int pixel_type = CTIFF_PIXEL_UINT16; int pixel_bit_depth = ((pixel_type >> 4) + 0x01) << 3; void* buffer; unsigned int k; int retval = 0; const void *buf; char *output_path = "output.tif"; char *artist = "Artist"; char *copyright = "Copyright"; char *make = "Camera Manufacturer"; char *model = "Camera Model"; char *software = "Software"; char *image_desc = "Created through include statements."; char *meta_ptr; char metadata[][80] = {"{\"key with spaces\": \r\n\t \"data with spaces 1\"}", "{\"numeric_data\": 1337 }", "{\"boolean data\": true}", "{\"array data\": [ [ 1, 2, 3], [4, 5, 6], [7, 8, 9]]}", "{ \"bad json\" 42}", ""}; TRYFUNC(calculateImageArrays(width, height, pages, pixel_bit_depth, &buffer), "Could not calclate buffer.") DEBUGP("Calculated buffer.") CTIFF ctiff = CTIFFNew(output_path); CTIFFWriteEvery(ctiff, 1); CTIFFSetStyle(ctiff, width, height, pixel_type, false); CTIFFSetRes(ctiff, 72, 72); // Not needed, defaults to strict = true CTIFFSetStrict(ctiff,true); CTIFFSetBasicMeta(ctiff, artist, copyright, make, model, software, image_desc); for (k = 0; k < pages; k++){ buf = moveArrayPtr(buffer, k*width*height, pixel_bit_depth); meta_ptr = (k == 0) ? NULL : metadata[k-1]; if ((retval = CTIFFAddNewPage(ctiff, buf, "meta", meta_ptr)) != 0){ printf("Could not add image\n"); CTIFFClose(ctiff); return retval; } // This will return an error because at least one of the pages has already // been written to disk. /* * if (CTIFFSetStrict(ctiff,false) != 0) { * printf("Could not change the strictness of the CTIFF.\n"); * } */ } retval = CTIFFWrite(ctiff); CTIFFClose(ctiff); DEBUGP("Wrote TIFF.") destroyBuffer(buffer); return retval; }
void pythExample::sayHallo() { TRYFUNC( this->get_override("sayHallo")()); }
void pythExample::setMsg(const char* msg) { TRYFUNC( this->get_override("setMsg")(msg)); }
void findfilts(flidomain_t domain, filt_t **filt) { long r; char **tmplist; TRYFUNC(FLIList, domain | FLIDEVICE_FILTERWHEEL, &tmplist); if (tmplist != NULL && tmplist[0] != NULL) { int i, filts = 0; for (i = 0; tmplist[i] != NULL; i++) filts++; if ((*filt = realloc(*filt, (numfilts + filts) * sizeof(filt_t))) == NULL) err(1, "realloc() failed"); for (i = 0; tmplist[i] != NULL; i++) { int j; filt_t *tmpfilt = *filt + i; for (j = 0; tmplist[i][j] != '\0'; j++) if (tmplist[i][j] == ';') { tmplist[i][j] = '\0'; break; } tmpfilt->domain = domain; switch (domain) { case FLIDOMAIN_PARALLEL_PORT: tmpfilt->dname = "parallel port"; break; case FLIDOMAIN_USB: tmpfilt->dname = "USB"; break; case FLIDOMAIN_SERIAL: tmpfilt->dname = "serial"; break; case FLIDOMAIN_INET: tmpfilt->dname = "inet"; break; default: tmpfilt->dname = "Unknown domain"; break; } tmpfilt->name = strdup(tmplist[i]); } numfilts += filts; } TRYFUNC(FLIFreeList, tmplist); return; }
int main(int argc, char *argv[]) { int i = 0, filter = 0; long r; char libver[LIBVERSIZ]; filt_t *filt = NULL; flidev_t dev; long tmp1; #define BUFF_SIZ (1024) char buff[BUFF_SIZ]; if (argc != 2) usage("No filter position given"); filter = atol(argv[1]); TRYFUNC(FLISetDebugLevel, NULL /* "NO HOST" */, FLIDEBUG_ALL); TRYFUNC(FLIGetLibVersion, libver, LIBVERSIZ); info("Library version '%s'", libver); // XXX /* Parallel port */ //findfilts(FLIDOMAIN_PARALLEL_PORT, &filt); /* USB */ findfilts(FLIDOMAIN_USB, &filt); /* Serial */ //findfilts(FLIDOMAIN_SERIAL, &filt); /* Inet */ //findfilts(FLIDOMAIN_INET, &filt); if (numfilts == 0) info("No filter wheels found."); else { info("Trying filter wheel '%s' from %s domain", filt[i].name, filt[i].dname); TRYFUNC(FLIOpen, &dev, filt[i].name, FLIDEVICE_FILTERWHEEL | filt[i].domain); TRYFUNC(FLIGetModel, dev, buff, BUFF_SIZ); info("Model: %s", buff); TRYFUNC(FLIGetHWRevision, dev, &tmp1); info("Hardware Rev: %ld", tmp1); TRYFUNC(FLIGetFWRevision, dev, &tmp1); info("Firmware Rev: %ld", tmp1); TRYFUNC(FLISetFilterPos, dev, filter); TRYFUNC(FLIClose, dev); } for (i = 0; i < numfilts; i++) free(filt[i].name); free(filt); exit(0); }