summaryrefslogtreecommitdiffstats
path: root/kfaxview/libkfaximage/kfaximage.h
blob: 52dd77367bc02bb017807cc102475c7c02b5c9ba (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* 
   This file is part of KDE FAX image loading library
   Copyright (c) 2005 Helge Deller <[email protected]>
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.
   
   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef _LIBKFAXIMAGE_H_
#define _LIBKFAXIMAGE_H_

#include <tqobject.h>
#include <tqstring.h>
#include <tqimage.h>
#include <tqptrlist.h>
#include <kdelibs_export.h>

class pagenode;


/**
 *  This is KFaxImage, a class for loading FAX files under KDE
 *
 *  @short KFaxImage
 *  @author Helge Deller
 *  @version 0.1
 *
 *
 *  Standard fax dpi values:
 *  ------------------------
 *   Standard:		203 dpi x 98 lpi
 *   Fine:		203 dpi x 196 lpi
 *   Super Fine:	203 dpi y 392 lpi,  or
 *			406 dpi x 392 lpi
 */

#define KFAX_DPI_STANDARD	TQPoint(203,98)
#define KFAX_DPI_FINE		TQPoint(203,196)
#define KFAX_DPI_SUPERFINE	TQPoint(406,392)


class KDE_EXPORT KFaxImage : public TQObject
{
    Q_OBJECT
  TQ_OBJECT

public:

    /**
     *  KFaxImage - the KDE FAX loader class
     *  constructor.
     *  @param filename: an optional FAX file which should be loaded.
     *  @see: numPages
     */

    KFaxImage( const TQString &filename = TQString(), TQObject *tqparent = 0, const char *name = 0 );

    /**
     *  Destructor
     *
     *  releases internal allocated memory.
     */

    virtual ~KFaxImage();

    /**
     *  loads the FAX image and returns true when sucessful.
     *  @param filename: the file which should be loaded.
     *  @return boolean value on success or failure
     *  @see: numPages
     *  @see: errorString
     */

    bool loadImage( const TQString &filename );

    /**
     *  returns currently loaded image file name.
     *  @return FAX filename
     */

    TQString filename() { return m_filename; };

    /**
     *  returns number of pages which are stored in the FAX file
     *  @return page count
     */

    unsigned int numPages() const { return m_pagenodes.count(); };

    /**
     *  returns a TQImage which holds the contents of page pageNr
     *  @param pageNr: page number (starting with 0)
     *  @return TQImage of the page pageNr
     */

    TQImage page( unsigned int pageNr );

    /**
     *  returns the DPI (dots per inch) of page pageNr
     *  @param pageNr: page number (starting with 0)
     *  @return a TQPoint value with the DPIs in X- and Y-direction
     */

    TQPoint page_dpi( unsigned int pageNr );

    /**
     *  returns the physical pixels of page pageNr
     *  @param pageNr: page number (starting with 0)
     *  @return a TQSize value with the width and height of the image
     */

    TQSize page_size( unsigned int pageNr );

    /**
     *  @return a user-visible, translated error string
     */

    const TQString errorString() const { return m_errorString; };



  private:

    /**
     *  private member variables
     */

    TQString m_filename;
    TQString m_errorString;

    typedef TQPtrList<pagenode> t_PageNodeList;
    t_PageNodeList m_pagenodes;

    /**
     *  private member functions
     */

    void reset();
    void kfaxerror(const TQString& error);
    pagenode *AppendImageNode(int type);
    bool NewImage(pagenode *pn, int w, int h);
    void FreeImage(pagenode *pn);
    unsigned char *getstrip(pagenode *pn, int strip);
    int GetPartImage(pagenode *pn, int n);
    int GetImage(pagenode *pn);
    pagenode *notefile(int type);
    int notetiff();
    void badfile(pagenode *pn);
};

#endif /* _LIBKFAXIMAGE_H_ */