47 #ifndef VIGRA_CODEC_HXX
48 #define VIGRA_CODEC_HXX
54 #include "array_vector.hxx"
57 #include "sized_int.hxx"
77 static std::string result() {
return "undefined"; }
81 struct TypeAsString<
Int8>
83 static std::string result() {
return "INT8"; }
87 struct TypeAsString<
UInt8>
89 static std::string result() {
return "UINT8"; }
93 struct TypeAsString<
Int16>
95 static std::string result() {
return "INT16"; }
99 struct TypeAsString<
UInt16>
101 static std::string result() {
return "UINT16"; }
105 struct TypeAsString<
Int32>
107 static std::string result() {
return "INT32"; }
111 struct TypeAsString<
UInt32>
113 static std::string result() {
return "UINT32"; }
117 struct TypeAsString<float>
119 static std::string result() {
return "FLOAT"; }
123 struct TypeAsString<double>
125 static std::string result() {
return "DOUBLE"; }
132 std::string fileType;
133 std::vector<std::string> pixelTypes;
134 std::vector<std::string> compressionTypes;
135 std::vector<std::vector<char> > magicStrings;
136 std::vector<std::string> fileExtensions;
137 std::vector<int> bandNumbers;
145 virtual ~Decoder() {};
146 virtual void init(
const std::string & ) = 0;
147 virtual void close() = 0;
148 virtual void abort() = 0;
150 virtual std::string getFileType()
const = 0;
151 virtual std::string getPixelType()
const = 0;
153 virtual unsigned int getWidth()
const = 0;
154 virtual unsigned int getHeight()
const = 0;
155 virtual unsigned int getNumBands()
const = 0;
156 virtual unsigned int getNumExtraBands()
const
166 virtual float getXResolution()
const
170 virtual float getYResolution()
const
175 virtual unsigned int getOffset()
const = 0;
177 virtual const void * currentScanlineOfBand(
unsigned int )
const = 0;
178 virtual void nextScanline() = 0;
180 typedef ArrayVector<unsigned char> ICCProfile;
182 const ICCProfile & getICCProfile()
const
187 ICCProfile iccProfile_;
192 virtual ~Encoder() {};
193 virtual void init(
const std::string & ) = 0;
194 virtual void close() = 0;
195 virtual void abort() = 0;
197 virtual std::string getFileType()
const = 0;
198 virtual unsigned int getOffset()
const = 0;
200 virtual void setWidth(
unsigned int ) = 0;
201 virtual void setHeight(
unsigned int ) = 0;
202 virtual void setNumBands(
unsigned int ) = 0;
203 virtual void setCompressionType(
const std::string &,
int = -1 ) = 0;
204 virtual void setPixelType(
const std::string & ) = 0;
205 virtual void finalizeSettings() = 0;
210 virtual void setXResolution(
float )
213 virtual void setYResolution(
float )
217 typedef ArrayVector<unsigned char> ICCProfile;
219 virtual void setICCProfile(
const ICCProfile & )
223 virtual void * currentScanlineOfBand(
unsigned int ) = 0;
224 virtual void nextScanline() = 0;
226 struct TIFFCompressionException {};
233 virtual CodecDesc getCodecDesc()
const = 0;
234 virtual std::auto_ptr<Decoder> getDecoder()
const = 0;
235 virtual std::auto_ptr<Encoder> getEncoder()
const = 0;
236 virtual ~CodecFactory() {};
246 VIGRA_EXPORT std::auto_ptr<Decoder>
247 getDecoder(
const std::string &,
const std::string & =
"undefined" );
249 VIGRA_EXPORT std::auto_ptr<Encoder>
250 getEncoder(
const std::string &,
const std::string & =
"undefined" );
252 VIGRA_EXPORT std::string
253 getEncoderType(
const std::string &,
const std::string & =
"undefined" );
257 VIGRA_EXPORT std::vector<std::string> queryCodecPixelTypes(
const std::string & );
259 VIGRA_EXPORT
bool negotiatePixelType( std::string
const & codecname,
260 std::string
const & srcPixeltype, std::string & destPixeltype);
262 VIGRA_EXPORT
bool isPixelTypeSupported(
const std::string &,
const std::string & );
264 VIGRA_EXPORT
bool isBandNumberSupported(
const std::string &,
int bands );
267 #endif // VIGRA_CODEC_HXX