summaryrefslogtreecommitdiffstats
path: root/tdeio/tdeio/kimageiofactory.h
blob: 13312a2a29d9919e0856bde30fe18b7c03e46d94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* kimgio.h -- Declaration of interface to the KDE Image IO library.
* Sirtaj Singh Kang <taj@kde.org>, 23 Sep 1998.
*
* This library is distributed under the conditions of the GNU LGPL.
*/

#ifndef SSK_KIMGIOFACTORY_H
#define SSK_KIMGIOFACTORY_H

#include "tdesycocafactory.h"
#include "kimageio.h"

class KImageIOFormat;
class KImageIOFormatList;

/** \internal */
class TDEIO_EXPORT KImageIOFormat : public KSycocaEntry
{
  K_SYCOCATYPE( KST_KImageIOFormat, KSycocaEntry )

public:
  typedef TDESharedPtr<KImageIOFormat> Ptr;
  typedef TQValueList<Ptr> List;
public: // KDoc seems to barf on those typedefs and generates no docs after them
  /**
   * Read a KImageIOFormat description file
   */
  KImageIOFormat( const TQString & path);
  
  /**
   * @internal construct a ImageIOFormat from a stream
   */ 
  KImageIOFormat( TQDataStream& _str, int offset);

  virtual ~KImageIOFormat();

  virtual TQString name() const { return mType; }

  virtual bool isValid() const { return true; } 

  /**
   * @internal
   * Load the image format from a stream.
   */
  virtual void load(TQDataStream& ); 

  /**
   * @internal
   * Save the image format to a stream.
   */
  virtual void save(TQDataStream& );

  /**
   * @internal 
   * Calls image IO function
   */
  void callLibFunc( bool read, TQImageIO *);

public:  
  TQString mType;
  TQString mHeader;
  TQString mFlags;
  bool bRead;
  bool bWrite;
  TQStringList mSuffices;
  TQString mPattern;
  TQString mMimetype;
  TQString mLib;
  TQStringList rPaths;
  bool bLibLoaded;
  void (*mReadFunc)(TQImageIO *);
  void (*mWriteFunc)(TQImageIO *);
protected:
  virtual void virtual_hook( int id, void* data );
};

/** \internal */
class TDEIO_EXPORT KImageIOFormatList : public KImageIOFormat::List
{
public:
   KImageIOFormatList() { }
};


/** \internal */
class TDEIO_EXPORT KImageIOFactory : public KSycocaFactory
{
  friend class KImageIO;
  K_SYCOCAFACTORY( KST_KImageIO )
public:
  static KImageIOFactory *self() 
  { if (!_self) new KImageIOFactory(); return _self; }
  KImageIOFactory();
  virtual ~KImageIOFactory();

protected: // Internal stuff
  /**
   * @internal
   *
   * Load information from database
   */
  void load();

  /**
   * @internal Create pattern string
   **/
  TQString createPattern( KImageIO::Mode _mode);

  /**
   * @internal Not used.
   */
  virtual KSycocaEntry *createEntry(const TQString &, const char *)
    { return 0; }                                                    

  /**
   * @internal 
   */
  virtual KSycocaEntry *createEntry(int offset);

  /**
   * @internal Read an image
   **/
  static void readImage( TQImageIO *iio);

  /**
   * @internal Write an image
   **/
  static void writeImage( TQImageIO *iio);
  
protected:
  static KImageIOFactory *_self;  
  static KImageIOFormatList *formatList;
  TQString mReadPattern;
  TQString mWritePattern;
  TQStringList rPath;
protected:
    virtual void virtual_hook( int id, void* data );
};

#endif