| #pragma once |
| |
| #ifndef TIMAGE_IO_INCLUDED |
| #define TIMAGE_IO_INCLUDED |
| |
| |
| |
| |
| #include <QStringList> |
| |
| #include "tfilepath_io.h" |
| #include "traster.h" |
| #include "timage.h" |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TIMAGE_IO_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| namespace Tiio { |
| class Reader; |
| class Writer; |
| class VectorReader; |
| class VectorWriter; |
| } |
| class TPropertyGroup; |
| class TImageInfo; |
| |
| |
| |
| class DVAPI TImageException final : public TException { |
| TFilePath m_fp; |
| |
| public: |
| TImageException(const TFilePath &fp, const std::string &msg); |
| ~TImageException() {} |
| |
| TString getMessage() const override; |
| TString getRawMessage() const { return TException::getMessage(); } |
| const TFilePath &getFilePath() const { return m_fp; } |
| }; |
| |
| |
| |
| class DVAPI TImageVersionException final : public TException { |
| TFilePath m_fp; |
| int m_major, m_minor; |
| |
| public: |
| TImageVersionException(const TFilePath &fp, int major, int minor); |
| ~TImageVersionException() {} |
| |
| void getVersion(int &major, int &minor) const { |
| major = m_major; |
| minor = m_minor; |
| } |
| int getMajor() const { return m_major; } |
| int getMinor() const { return m_minor; } |
| }; |
| |
| |
| |
| |
| |
| |
| |
| class TImageReader; |
| typedef TImageReader *TImageReaderCreateProc(const TFilePath &path); |
| |
| |
| |
| |
| |
| class DVAPI TImageReader : public TSmartObject { |
| DECLARE_CLASS_CODE |
| |
| friend class TImageReaderP; |
| |
| protected: |
| |
| TFilePath m_path; |
| FILE *m_file; |
| Tiio::Reader *m_reader; |
| Tiio::VectorReader *m_vectorReader; |
| void open(); |
| void close(); |
| bool isOpen() const; |
| bool m_readGreytones; |
| bool m_is64BitEnabled; |
| int m_shrink; |
| TRect m_region; |
| static bool m_safeMode; |
| |
| public: |
| static void setSafeModeReadingForTzl(bool activated) { |
| m_safeMode = activated; |
| } |
| TImageReader(const TFilePath &path); |
| virtual ~TImageReader(); |
| |
| private: |
| |
| TImageReader(const TImageReader &); |
| TImageReader &operator=(const TImageReader &src); |
| TImageP load0(); |
| |
| public: |
| |
| virtual const TImageInfo *getImageInfo() const; |
| |
| TFilePath getFilePath() const { return m_path; }; |
| |
| TPropertyGroup *getProperties(); |
| void setProperties(const TPropertyGroup *); |
| |
| |
| |
| |
| |
| |
| |
| |
| virtual TImageP load(); |
| |
| void load(const TRasterP &ras, const TPoint &pos = TPoint(0, 0), |
| int shrinkX = 1, int shrinkY = 1); |
| |
| static bool load(const TFilePath &, TRasterP &); |
| static bool load(const TFilePath &, TImageP &); |
| |
| |
| virtual TImageP loadIcon() { return TImageP(); } |
| |
| static void getSupportedFormats(QStringList &names); |
| |
| |
| |
| |
| static void define(QString extension, TImageReaderCreateProc *proc); |
| |
| void doReadGraytones(bool readThem); |
| void enable16BitRead(bool is64bitEnabled) { |
| m_is64BitEnabled = is64bitEnabled; |
| } |
| |
| int getShrink() const { return m_shrink; } |
| |
| |
| |
| |
| |
| |
| |
| |
| void setShrink(int shrink); |
| |
| |
| |
| |
| |
| void setRegion(TRect rect) { m_region = rect; } |
| |
| |
| |
| |
| TRect getRegion() const { return m_region; } |
| |
| void getTzpPaletteColorNames( |
| std::map<int, std::pair<std::string, std::string>> |
| &pltColorNames); |
| }; |
| |
| |
| |
| #ifdef _WIN32 |
| template class DVAPI TSmartPointerT<TImageReader>; |
| #endif |
| |
| class DVAPI TImageReaderP final : public TSmartPointerT<TImageReader> { |
| public: |
| TImageReaderP(TImageReader *ir) : TSmartPointerT<TImageReader>(ir){}; |
| |
| TImageReaderP(const TFilePath &filepath); |
| }; |
| |
| |
| |
| |
| |
| |
| |
| class TImageWriter; |
| typedef TImageWriter *TImageWriterCreateProc(const TFilePath &path); |
| |
| |
| |
| |
| |
| class DVAPI TImageWriter : public TSmartObject { |
| DECLARE_CLASS_CODE |
| |
| protected: |
| |
| TFilePath m_path; |
| |
| Tiio::Writer *m_writer; |
| Tiio::VectorWriter *m_vectorWriter; |
| TPropertyGroup *m_properties; |
| |
| public: |
| TImageWriter(const TFilePath &path); |
| virtual ~TImageWriter(); |
| |
| private: |
| |
| TImageWriter(const TImageWriter &); |
| TImageWriter &operator=(const TImageWriter &src); |
| |
| public: |
| TFilePath getFilePath() const { return m_path; }; |
| |
| |
| void setProperties(const TPropertyGroup *); |
| |
| virtual void save(const TImageP &img); |
| virtual bool is64bitOutputSupported() { return true; } |
| static void save(const TFilePath &, TRasterP); |
| static void save(const TFilePath &, const TImageP &); |
| |
| static void getSupportedFormats(QStringList &names, bool onlyRenderFormats); |
| |
| static void define(QString extension, TImageWriterCreateProc *proc, |
| bool isRenderFormat); |
| }; |
| |
| |
| |
| #ifdef _WIN32 |
| template class DVAPI TSmartPointerT<TImageWriter>; |
| #endif |
| |
| class DVAPI TImageWriterP final : public TSmartPointerT<TImageWriter> { |
| public: |
| TImageWriterP(TImageWriter *iw) : TSmartPointerT<TImageWriter>(iw){}; |
| |
| TImageWriterP(const TFilePath &filepath); |
| }; |
| |
| |
| |
| |
| |
| |
| |
| class TImageReaderWriter; |
| typedef TImageReaderWriter *TImageReaderWriterCreateProc(const TFilePath &path); |
| |
| |
| |
| #endif |