File indexing completed on 2024-05-12 16:06:42
0001 /* 0002 Include file for fax routines 0003 This file is part of viewfax - g3/g4 fax processing software. 0004 0005 SPDX-FileCopyrightText: 1990, 1995 Frank D. Cringle. 0006 SPDX-FileCopyrightText: 2005 Helge Deller <deller@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef _faxexpand_h_ 0012 #define _faxexpand_h_ 0013 0014 #include <QImage> 0015 0016 #include <sys/types.h> 0017 #ifndef Q_OS_WIN 0018 #include <unistd.h> 0019 #endif 0020 0021 #define t32bits quint32 0022 #define t16bits quint16 0023 0024 typedef t16bits pixnum; 0025 0026 class pagenode; 0027 0028 /* drawfunc() points to a function which processes a line of the 0029 expanded image described as a list of run lengths. 0030 run is the base of an array of lengths, starting with a 0031 (possibly empty) white run for line number linenum. 0032 pn points to the page descriptor */ 0033 typedef void (*drawfunc)(pixnum *run, int linenum, class pagenode *pn); 0034 0035 struct strip { /* tiff strip descriptor */ 0036 off_t offset; /* offset in file */ 0037 off_t size; /* size of this strip */ 0038 }; 0039 0040 /* defines for the pagenode member: type */ 0041 #define FAX_TIFF 1 0042 #define FAX_RAW 2 0043 0044 class pagenode 0045 { /* compressed page descriptor */ 0046 public: 0047 pagenode(); 0048 ~pagenode() 0049 { 0050 } 0051 int nstrips; /* number of strips */ 0052 int rowsperstrip; /* number of rows per strip */ 0053 int stripnum; /* current strip while expanding */ 0054 struct strip *strips; /* array of strips containing fax data in file */ 0055 t16bits *data; /* in-memory copy of strip */ 0056 t16bits *dataOrig; /* copy of `data', in case we shift it */ 0057 size_t length; /* length of data */ 0058 QSize size; /* width & height of page in pixels */ 0059 int inverse; /* black <=> white */ 0060 int lsbfirst; /* bit order is lsb first */ 0061 int orient; /* orientation - upsidedown, landscape, mirrored */ 0062 int vres; /* vertical resolution: 1 = fine */ 0063 QPoint dpi; /* DPI horz/vert */ 0064 void (*expander)(class pagenode *, drawfunc); 0065 unsigned int bytes_per_line; 0066 QString filename; /* The name of the file to be opened */ 0067 QImage image; /* The final image */ 0068 uchar *imageData; /* The temporary raw image data */ 0069 }; 0070 0071 /* page orientation flags */ 0072 #define TURN_NONE 0 0073 #define TURN_U 1 0074 #define TURN_L 2 0075 #define TURN_M 4 0076 0077 /* fsm state codes */ 0078 #define S_Null 0 0079 #define S_Pass 1 0080 #define S_Horiz 2 0081 #define S_V0 3 0082 #define S_VR 4 0083 #define S_VL 5 0084 #define S_Ext 6 0085 #define S_TermW 7 0086 #define S_TermB 8 0087 #define S_MakeUpW 9 0088 #define S_MakeUpB 10 0089 #define S_MakeUp 11 0090 #define S_EOL 12 0091 0092 /* state table entry */ 0093 struct tabent { 0094 unsigned char State; 0095 unsigned char Width; /* width of code in bits */ 0096 pixnum Param; /* run length */ 0097 }; 0098 0099 extern struct tabent MainTable[]; /* 2-D state table */ 0100 extern struct tabent WhiteTable[]; /* White run lengths */ 0101 extern struct tabent BlackTable[]; /* Black run lengths */ 0102 0103 void MHexpand(class pagenode *pn, drawfunc df); 0104 void g31expand(class pagenode *pn, drawfunc df); 0105 void g32expand(class pagenode *pn, drawfunc df); 0106 void g4expand(class pagenode *pn, drawfunc df); 0107 0108 /* initialise code tables */ 0109 extern void fax_init_tables(); 0110 0111 /* count lines in image */ 0112 extern int G3count(class pagenode *pn, int twoD); 0113 0114 #endif