Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TIIO_INCLUDED
Toshihiro Shimizu 890ddd
#define TIIO_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include <string></string>
Toshihiro Shimizu 890ddd
#include <qstringlist></qstringlist>
Toshihiro Shimizu 890ddd
#include "timageinfo.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TNZCORE_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TVectorImage;
Toshihiro Shimizu 890ddd
class TPropertyGroup;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace Tiio {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
enum RowOrder { BOTTOM2TOP, TOP2BOTTOM };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI Exception {};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI Reader {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TImageInfo m_info;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Reader();
Shinya Kitaoka 120a6e
  virtual ~Reader();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void open(FILE *file) = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const TImageInfo &getImageInfo() const { return m_info; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual TPropertyGroup *getProperties() const { return 0; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void readLine(char *buffer) { readLine(buffer, 0, m_info.m_lx - 1, 1); }
Shinya Kitaoka 120a6e
  void readLine(short *buffer) { readLine(buffer, 0, m_info.m_lx - 1, 1); }
shun-iwasawa 481b59
  void readLine(float *buffer) { readLine(buffer, 0, m_info.m_lx - 1, 1); }
Shinya Kitaoka 120a6e
  virtual void readLine(char *buffer, int x0, int x1, int shrink) = 0;
Shinya Kitaoka 120a6e
  virtual void readLine(short *, int, int, int) { assert(false); }
shun-iwasawa 481b59
  virtual void readLine(float *, int, int, int) { assert(false); }
Shinya Kitaoka 120a6e
  // Returns skipped lines number.
Shinya Kitaoka 120a6e
  // If not implemented returns 0;
Shinya Kitaoka 120a6e
  virtual int skipLines(int lineCount) = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual RowOrder getRowOrder() const { return BOTTOM2TOP; }
Shinya Kitaoka 120a6e
  virtual bool read16BitIsEnabled() const { return false; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // this function enables/disables the 64 bit reading.
Shinya Kitaoka 120a6e
  // If disabled, 64 bit images will be automatically  scaled down to 32 bit.
Shinya Kitaoka 120a6e
  // The default behaviour for formats that support 64 bit images is "Enabled"
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void enable16BitRead(bool) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void getTzpPaletteColorNames(
Shinya Kitaoka 120a6e
      std::map<int, std::pair<std::string,="" std::string="">> &pltColorNames) const {</int,>
Shinya Kitaoka 120a6e
    assert(false);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
shun-iwasawa 481b59
  // gamma value to be used for converting linear-based image file to nonlinear
shun-iwasawa 481b59
  // raster. Curretly only used in EXR images.
shun-iwasawa 481b59
  virtual void setColorSpaceGamma(const double) {}
shun-iwasawa 481b59
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  Reader(const Reader &);
Shinya Kitaoka 120a6e
  Reader &operator=(const Reader &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI Writer {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TImageInfo m_info;
Shinya Kitaoka 120a6e
  TPropertyGroup *m_properties;
Shinya Kitaoka 120a6e
  static int m_bwThreshold;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  static void getSupportedFormats(QStringList &formats, bool onlyRenderFormats);
Shinya Kitaoka 120a6e
  static void setBlackAndWhiteThreshold(int threshold) {
Shinya Kitaoka 120a6e
    m_bwThreshold = threshold;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  Writer();
Shinya Kitaoka 120a6e
  virtual ~Writer();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void open(FILE *file, const TImageInfo &inafo) = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPropertyGroup *getProperties() { return m_properties; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void writeLine(char *buffer) = 0;
Shinya Kitaoka 120a6e
  virtual void writeLine(short *) { assert(false); }
shun-iwasawa 481b59
  virtual void writeLine(float *) { assert(false); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void flush() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual RowOrder getRowOrder() const { return BOTTOM2TOP; }
Shinya Kitaoka 120a6e
  virtual bool write64bitSupported() const { return false; }
shun-iwasawa 93fdd4
  virtual bool writeAlphaSupported() const { return true; }
shun-iwasawa 481b59
  // only true in EXR format
shun-iwasawa 481b59
  virtual bool writeInLinearColorSpace() const { return false; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setProperties(TPropertyGroup *properties);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  Writer(const Writer &);
Shinya Kitaoka 120a6e
  Writer &operator=(const Writer &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI VectorReader {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  VectorReader() {}
Shinya Kitaoka 120a6e
  virtual ~VectorReader() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void open(FILE *file) = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual TVectorImage *read() = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI VectorWriter {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  VectorWriter() {}
Shinya Kitaoka 120a6e
  virtual ~VectorWriter() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void open(FILE *file)      = 0;
Shinya Kitaoka 120a6e
  virtual void write(TVectorImage *) = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef Reader *ReaderMaker();
Toshihiro Shimizu 890ddd
typedef Writer *WriterMaker();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef VectorReader *VectorReaderMaker();
Toshihiro Shimizu 890ddd
typedef VectorWriter *VectorWriterMaker();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI Tiio::Reader *makeReader(std::string ext);
Toshihiro Shimizu 890ddd
DVAPI Tiio::Writer *makeWriter(std::string ext);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI Tiio::VectorReader *makeVectorReader(std::string ext);
Toshihiro Shimizu 890ddd
DVAPI Tiio::VectorWriter *makeVectorWriter(std::string ext);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI TPropertyGroup *makeWriterProperties(std::string ext);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI void defineReaderMaker(const char *ext, Tiio::ReaderMaker *fn);
Shinya Kitaoka 120a6e
DVAPI void defineWriterMaker(const char *ext, Tiio::WriterMaker *fn,
Shinya Kitaoka 120a6e
                             bool isRenderFormat);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
DVAPI void defineVectorReaderMaker(const char *ext,
Shinya Kitaoka 120a6e
                                   Tiio::VectorReaderMaker *fn);
Shinya Kitaoka 120a6e
DVAPI void defineVectorWriterMaker(const char *ext, Tiio::VectorWriterMaker *fn,
Shinya Kitaoka 120a6e
                                   bool isRenderFormat);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI void defineWriterProperties(const char *ext, TPropertyGroup *);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI bool isQuicktimeInstalled();
Toshihiro Shimizu 890ddd
justburner f0c501
DVAPI bool useQuicktime(bool enable = false);
justburner f0c501
shun-iwasawa e87e08
DVAPI void updateFileWritersPropertiesTranslation();
shun-iwasawa e87e08
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
shun-iwasawa 481b59
}  // namespace Tiio
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif