areaDetector  3-13
EPICS areaDetector framework
NDFileJPEG.h
Go to the documentation of this file.
1 /*
2  * NDFileJPEG.h
3  * Writes NDArrays to JPEG files.
4  * Mark Rivers
5  * May 9, 2009
6  */
7 
8 #ifndef DRV_NDFileJPEG_H
9 #define DRV_NDFileJPEG_H
10 
11 #include "NDPluginFile.h"
12 
13 #ifdef __cplusplus
14 // Force C interface for jpeg functions
15 extern "C" {
16 #endif
17 #include "jpeglib.h"
18 #ifdef __cplusplus
19 }
20 #endif
21 
22 #define JPEG_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
23 
25 typedef struct {
26  struct jpeg_destination_mgr pub; /* public fields */
27  class NDFileJPEG *pNDFileJPEG; /* Pointer to ourselves */
28 } jpegDestMgr;
29 
30 #define NDFileJPEGQualityString "JPEG_QUALITY" /* (asynInt32, r/w) File quality */
31 
36 public:
37  NDFileJPEG(const char *portName, int queueSize, int blockingCallbacks,
38  const char *NDArrayPort, int NDArrayAddr,
39  int priority, int stackSize);
40 
41  /* The methods that this class implements */
42  virtual asynStatus openFile(const char *fileName, NDFileOpenMode_t openMode, NDArray *pArray);
43  virtual asynStatus readFile(NDArray **pArray);
44  virtual asynStatus writeFile(NDArray *pArray);
45  virtual asynStatus closeFile();
46  /* These should be private, but are called from C, must be public */
47  void initDestination();
48  boolean emptyOutputBuffer();
49  void termDestination();
50 
51 protected:
53  #define FIRST_NDFILE_JPEG_PARAM NDFileJPEGQuality
54 
55 private:
56  struct jpeg_compress_struct jpegInfo;
57  struct jpeg_error_mgr jpegErr;
59  FILE *outFile;
60  JOCTET jpegBuffer[JPEG_BUF_SIZE];
61  jpegDestMgr destMgr;
62 };
63 
64 #endif
NDColorMode_t colorMode
Definition: ADPylon.cpp:59
NDColorMode_t
Enumeration of color modes for NDArray attribute "colorMode".
Definition: NDArray.h:35
#define JPEG_BUF_SIZE
Definition: NDFileJPEG.h:22
#define NDPLUGIN_API
Definition: NDPluginAPI.h:41
int NDFileOpenMode_t
Definition: NDPluginFile.h:17
N-dimensional array class; each array has a set of dimensions, a data type, pointer to data,...
Definition: NDArray.h:99
Writes NDArrays in the JPEG file format, which is a lossy compression format.
Definition: NDFileJPEG.h:35
int NDFileJPEGQuality
Definition: NDFileJPEG.h:52
Base class for NDArray file writing plugins; actual file writing plugins inherit from this class.
Definition: NDPluginFile.h:28
virtual asynStatus readFile(NDArray **pArray)=0
Read NDArray data from a file; pure virtual function that must be implemented by derived classes.
virtual asynStatus closeFile()=0
Close the file opened with NDPluginFile::openFile; pure virtual function that must be implemented by ...
virtual asynStatus openFile(const char *fileName, NDFileOpenMode_t openMode, NDArray *pArray)=0
Open a file; pure virtual function that must be implemented by derived classes.
virtual asynStatus writeFile(NDArray *pArray)=0
Write NDArray data to a file; pure virtual function that must be implemented by derived classes.
Expanded data destination object for JPEG output.
Definition: NDFileJPEG.h:25
class NDFileJPEG * pNDFileJPEG
Definition: NDFileJPEG.h:27