9 #define WIN32_LEAN_AND_MEAN
23 static __declspec(dllexport)
bool WriteTiff (
const char* fileName,
int width,
int height,
24 int stride,
const unsigned short int * data,
25 bool rotate,
const char* tags =
nullptr);
27 static __declspec(dllexport)
bool WriteTiff (
const char* fileName,
int width,
int height,
28 int stride,
int bpp,
const unsigned char * data,
29 bool rotate,
const char* tags =
nullptr);
31 static __declspec(dllexport)
bool OpenMultipageTifFileWriteBuffer(
const char* qualifiedFilename,
33 const unsigned short int* buffer,
34 int width,
int height,
35 unsigned int bitsPerPixel,
36 bool rotate,
int location,
37 const char* tags =
nullptr);
38 static __declspec(dllexport)
bool WriteBufferToMultipageTifFile (
const unsigned short int* buffer,
39 int width,
int height,
40 unsigned int bitsPerPixel,
41 bool rotate,
int location,
42 const char* tags =
nullptr);
43 static __declspec(dllexport)
int GetNumPagesInMultipageTifFile (
const char* qualifiedFilename);
44 static __declspec(dllexport)
bool GetPageSizeInMultipageTifFile (
const char* qualifiedFilename,
45 int pageNum,
unsigned int* width,
48 static __declspec(dllexport)
bool OpenMultipageTifFileReadPage (
const char* qualifiedFilename,
50 unsigned short int* data,
51 char* tags =
nullptr);
52 static __declspec(dllexport)
bool OpenMultipageTifFileReadPage (
const char* qualifiedFilename,
55 char* tags =
nullptr);
56 static __declspec(dllexport)
bool ReadPageFromMultipageTifFile (
int pageNum,
57 unsigned short int* data,
58 char* tags =
nullptr);
59 static __declspec(dllexport)
bool ReadPageFromMultipageTifFile (
int pageNum,
61 char* tags =
nullptr);
62 static __declspec(dllexport)
bool CloseMultipageTifFile();
66 static __declspec(dllexport)
bool DirectoryExists (
const char* dir);
67 static __declspec(dllexport)
bool CreateADirectory (
const char* dir);
70 static __declspec(dllexport)
bool FileExists (
const char *filename);
71 static __declspec(dllexport)
bool IsValidFilename (
const char *filename);
73 static bool WriteTiff (
string fileName,
int width,
int height,
int stride,
74 const vector<unsigned short> data,
bool rotate);
75 static bool WriteTiff (
string fileName,
int width,
int height,
int stride,
int bpp,
76 const vector<unsigned char> data,
bool rotate);
79 static void SaveMemoryToTextFile(
int w,
int h, T* plot_data,
const char* fname)
82 string fullName(fname);
83 string fullName = fullName +
".txt";
84 myfile.open(fullName.c_str(), ios::out | ios::trunc);
85 for (
int r = 0; r < h; r++)
87 for (
int c = 0; c < w; c++)
90 myfile << *(plot_data + i) <<
" ";
98 static bool SaveMemoryToBinFile(
const char* fname,
int w,
int h,
const T* data)
100 return SaveMemoryToBinFile(fname, w * h, data);
103 template <
typename T>
104 static bool SaveMemoryToBinFile(
const char* fname,
int size,
const T* data)
107 if (fname && data && size > 0)
113 fout.open(fname, ios::out | ios::binary);
116 fout.write((
char*)data, size *
sizeof(T));
132 template <
typename T>
133 static bool LoadBinFileToMemory(
const char* fname,
int width,
int height, T* data)
135 return LoadBinFileToMemory(fname, width * height, data);
138 template <
typename T>
139 static bool LoadBinFileToMemory(
const char* fname,
int size, T* data)
142 if (fname && data && size > 0)
146 ifstream fin(fname, ios::binary | ios::ate);
151 fin.read((
char*)data, size *
sizeof(T));
168 static void SaveVector(vector<T> dataVec,
string fname)
171 string s = fname +
".txt";
172 myfile.open(s.c_str(), ios::out | ios::trunc);
173 for (
int i = 0; i < dataVec.size(); i++)
175 myfile << dataVec[i] <<
"\n";
181 static ostream& BinaryWrite(ostream& stream,
const T& value)
183 return stream.write(
reinterpret_cast<const char*
>(&value),
sizeof(T));
192 static inline void SaveVector(
int len, T* line_data,
string fname)
195 string s = fname +
".txt";
197 myfile.open(s.c_str(), ios::out | ios::trunc);
198 for (
int i = 0; i < len; i++)
200 myfile << *(line_data + i) <<
"\n";
209 static inline void SaveVector(
int start,
int len, T* line_data,
string fname)
212 string s = fname +
".txt";
214 myfile.open(s.c_str(), ios::out | ios::trunc);
215 for (
int i = 0; i < len; i++)
217 myfile << *(line_data + start + i) <<
"\n";
222 static string GetFirstFileMatch (
const string &directory,
const string& partialFileName);
223 static size_t GetFileSize (
const string& filename);
230 static vector<unsigned short int> _transposedShortData;
231 static vector<unsigned char> _transposedCharData;
233 static HINSTANCE _hinstLib;
235 static void LoadStorageUtils();
237 static bool SubstituteFileExtension (
string& filename,
const char* extension);
239 static bool WriteUsingTiffUtils (
const char* fileName,
int width,
int height,
int stride,
240 const unsigned short int * data,
241 const char* tags =
nullptr);
242 static bool WriteUsingTiffUtils (
const char* fileName,
int width,
int height,
int stride,
243 int bpp,
const unsigned char * data,
244 const char* tags =
nullptr);
245 static bool OpenWritePageUsingTiffUtils(
const char* qualifiedFilename,
bool create,
246 const unsigned short int* buffer,
int width,
247 int height,
unsigned int bitsPerPixel,
int location,
249 static bool WritePageUsingTiffUtils (
const unsigned short int* buffer,
int width,
250 int height,
unsigned int bitsPerPixel,
251 int location,
const char* tags);
252 static int GetNumPagesUsingTiffUtils (
const char* qualifiedFilename);
253 static bool GetPageSizeUsingTiffUtils (
const char* qualifiedFilename,
int pageNum,
254 unsigned int* width,
unsigned int* height,
256 static bool OpenReadPageUsingTiffUtils (
const char* qualifiedFilename,
int pageNum,
257 unsigned short int* data,
char* tags =
nullptr);
258 static bool ReadPageUsingTiffUtils (
int pageNum,
unsigned short int* data,
259 char* tags =
nullptr);
260 static bool OpenReadPageUsingTiffUtils (
const char* qualifiedFilename,
int pageNum,
261 unsigned char* data,
char* tags =
nullptr);
262 static bool ReadPageUsingTiffUtils (
int pageNum,
unsigned char* data,
char* tags =
nullptr);
263 static bool CloseUsingTiffUtils ();
Utility template functions.
__declspec(dllexport) IWPOCTCamera *GetOCTCamera(IWPOCTCamera __declspec(dllexport) IWPOCTCamera __declspec(dllexport) bool DestroyOCTCamera(IWPOCTCamera *camera
Gets the instance of the camera object.
Definition: IWPOCTController.cpp:29
Definition: FileUtils.h:21
static __declspec(dllexport) bool FileExists(const char *filename)
Test if file exists.
static void SaveVector(int len, T *line_data, string fname)
save the array to file
Definition: FileUtils.h:192
static void SaveVector(int start, int len, T *line_data, string fname)
save the array[start] - array[start + len] to file
Definition: FileUtils.h:209