cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
svlImageIO.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Balazs Vagvolgyi
7  Created on: 2006
8 
9  (C) Copyright 2006-2007 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 #ifndef _svlImageIO_h
23 #define _svlImageIO_h
24 
28 #include <string>
29 
30 // Always include last!
32 
33 
34 // Forward declarations
35 class svlSampleImage;
37 
38 /*************************************/
39 /*** svlImageCodecBase class *********/
40 /*************************************/
41 
43 {
45 public:
47  virtual ~svlImageCodecBase();
48 
49  const std::string& GetExtensions() const;
50 
51  virtual int ReadDimensions(const std::string &filename, unsigned int &width, unsigned int &height);
52  virtual int ReadDimensions(std::istream &stream, unsigned int &width, unsigned int &height);
53  virtual int ReadDimensions(const unsigned char *buffer, const size_t buffersize, unsigned int &width, unsigned int &height);
54 
55  virtual int Read(svlSampleImage &image, const unsigned int videoch, const std::string &filename, bool noresize = false);
56  virtual int Read(svlSampleImage &image, const unsigned int videoch, std::istream &stream, bool noresize = false);
57  virtual int Read(svlSampleImage &image, const unsigned int videoch, const unsigned char *buffer, const size_t buffersize, bool noresize = false);
58 
59  virtual int Write(const svlSampleImage &image, const unsigned int videoch, const std::string &filename, const int compression = -1);
60  virtual int Write(const svlSampleImage &image, const unsigned int videoch, std::ostream &stream, const int compression = -1);
61  virtual int Write(const svlSampleImage &image, const unsigned int videoch, std::ostream &stream, const std::string &codec, const int compression = -1);
62  virtual int Write(const svlSampleImage &image, const unsigned int videoch, unsigned char *buffer, size_t &buffersize, const int compression = -1);
63  virtual int Write(const svlSampleImage &image, const unsigned int videoch, unsigned char *buffer, size_t &buffersize, const std::string &codec, const int compression = -1);
64 
65 protected:
66  void SetExtensionList(const std::string &list);
67 
68 private:
69  std::string ExtensionList;
70 };
71 
73 
74 /***********************************/
75 /*** svlImageIO class **************/
76 /***********************************/
77 
79 {
80  friend void svlInitializeImageCodecs();
81 
82 private:
87 
88  svlImageIO();
89  svlImageIO(const svlImageIO &);
90  static svlImageIO* GetInstance();
91 
92  _CodecList Codecs;
93  _ExtensionList Extensions;
97 
98 public:
99  ~svlImageIO();
100 
101  static int GetExtension(const std::string &filename, std::string &extension);
102 
103  static svlImageCodecBase* GetCodec(const std::string &filename);
104  static void ReleaseCodec(svlImageCodecBase* codec);
105 
106  static int ReadDimensions(const std::string &filename, unsigned int &width, unsigned int &height);
107  static int ReadDimensions(const std::string &codec, std::istream &stream, unsigned int &width, unsigned int &height);
108  static int ReadDimensions(const std::string &codec, const unsigned char *buffer, const size_t buffersize, unsigned int &width, unsigned int &height);
109 
110  static int Read(svlSampleImage &image, const unsigned int videoch, const std::string &filename, bool noresize = false);
111  static int Read(svlSampleImage &image, const unsigned int videoch, const std::string &codec, std::istream &stream, bool noresize = false);
112  static int Read(svlSampleImage &image, const unsigned int videoch, const std::string &codec, const unsigned char *buffer, const size_t buffersize, bool noresize = false);
113 
114  static int Write(const svlSampleImage &image, const unsigned int videoch, const std::string &filename, const int compression = -1);
115  static int Write(const svlSampleImage &image, const unsigned int videoch, const std::string &codec, std::ostream &stream, const int compression = -1);
116  static int Write(const svlSampleImage &image, const unsigned int videoch, const std::string &codec, unsigned char *buffer, size_t &buffersize, const int compression = -1);
117 };
118 
119 
120 #endif // _svlImageIO_h
121 
Definition: svlImageIO.h:78
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: osaCriticalSection.h:36
Definition: svlImageIO.h:42
Base class for high level objects.
Definition: cmnGenericObject.h:51
Declaration of vctDynamicVector.
Defines cmnGenericObject.
Definition: svlSampleImage.h:35
Macros to export the symbols of cisstStereoVision (in a Dll).
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Base class for class services.
Definition: cmnClassServicesBase.h:45
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition: cmnClassRegisterMacros.h:202
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76