00001 /* 00002 * NDFileJPEG.h 00003 * Writes NDArrays to JPEG files. 00004 * Mark Rivers 00005 * May 9, 2009 00006 */ 00007 00008 #ifndef DRV_NDFileJPEG_H 00009 #define DRV_NDFileJPEG_H 00010 00011 #include "NDPluginFile.h" 00012 #include "jpeglib.h" 00013 00014 #define JPEG_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ 00015 00017 typedef struct { 00018 struct jpeg_destination_mgr pub; /* public fields */ 00019 class NDFileJPEG *pNDFileJPEG; /* Pointer to ourselves */ 00020 } jpegDestMgr; 00021 00022 #define NDFileJPEGQualityString "JPEG_QUALITY" /* (asynInt32, r/w) File quality */ 00023 00027 class NDFileJPEG : public NDPluginFile { 00028 public: 00029 NDFileJPEG(const char *portName, int queueSize, int blockingCallbacks, 00030 const char *NDArrayPort, int NDArrayAddr, 00031 int priority, int stackSize); 00032 00033 /* The methods that this class implements */ 00034 virtual asynStatus openFile(const char *fileName, NDFileOpenMode_t openMode, NDArray *pArray); 00035 virtual asynStatus readFile(NDArray **pArray); 00036 virtual asynStatus writeFile(NDArray *pArray); 00037 virtual asynStatus closeFile(); 00038 /* These should be private, but are called from C, must be public */ 00039 void initDestination(); 00040 boolean emptyOutputBuffer(); 00041 void termDestination(); 00042 00043 protected: 00044 int NDFileJPEGQuality; 00045 #define FIRST_NDFILE_JPEG_PARAM NDFileJPEGQuality 00046 #define LAST_NDFILE_JPEG_PARAM NDFileJPEGQuality 00047 00048 private: 00049 struct jpeg_compress_struct jpegInfo; 00050 struct jpeg_error_mgr jpegErr; 00051 NDColorMode_t colorMode; 00052 FILE *outFile; 00053 JOCTET jpegBuffer[JPEG_BUF_SIZE]; 00054 jpegDestMgr destMgr; 00055 }; 00056 #define NUM_NDFILE_JPEG_PARAMS (&LAST_NDFILE_JPEG_PARAM - &FIRST_NDFILE_JPEG_PARAM + 1) 00057 00058 #endif