1 /* encoder.hpp -- specific encoding filters 2 * by pts@fazekas.hu at Tue Feb 26 13:30:02 CET 2002 3 */ 4 5 #ifdef __GNUC__ 6 #ifndef __clang__ 7 #pragma interface 8 #endif 9 #endif 10 11 #ifndef ENCODER_HPP 12 #define ENCODER_HPP 1 13 14 #include "config2.h" 15 #include "gensio.hpp" 16 #include <stdio.h> 17 18 class PSEncoder: public Encoder { 19 public: 20 /** @return "Flate", "LZW", "DCT", "RunLength", "CCITTFax", "ASCIIHex", "ASCII85" */ 21 // inline char const* getLongname() const { return longname; } 22 /** @return "Fla", "LZW", "DCT", "RL", "CCF", "AHx", "A85" */ 23 // inline char const* getShortname() const { return shortname; } 24 // inline SimBuffer::Flat const& getFPSname() const { return filter_psname; } 25 // virtual void vi_write(char const*buf, slen_t len) =0; ~PSEncoder()26 inline virtual ~PSEncoder() {} 27 28 /* The class methods below may return different implementations according to 29 * the command line and compile-time options. 30 */ 31 static PSEncoder* newASCIIHexEncode(GenBuffer::Writable &out_,unsigned maxcpl_); 32 static PSEncoder* newASCII85Encode(GenBuffer::Writable &out_,unsigned maxcpl_); 33 /** Fax (PSL2 CCITTFaxEncode filter, Uncompressed=true! (parts of the data 34 * can be inserted uncompressed, when the decoder decides that this is 35 * advantageous), K=-1,0,positive, 36 * EndOfLine=false, EncodedByteAlign=false, Columns=..., Rows=0, 37 * EndOfBlock=true, BlackIs1=false, DamagedRowsBeforeError=0 38 * K must be -1, 0 or positive, see PLRM 3.13.3 39 * K==-1: Group 4 pure 2D encoding. TIFF COMPRESSION_CCITTFAX4, 40 * GROUP4OPT_UNCOMPRESSED. 41 * K==0: Group 3 pure 1D encoding. TIFF COMPRESSION_CCITTFAX3, 42 * GROUP3OPT_UNCOMPRESSED. 43 * K>=1: Group 3 2D (mixed 1D and 2D), a 1D-line can be followed by at most 44 * K-1 2D-line. TIFF COMPRESSION_CCITTFAX3, GROUP3OPT_UNCOMPRESSED, 45 * GROUP3OPT_2DENCODING (K is explicitly raised to image height). 46 * @param EndOfLine should be false for PS/PDF, but must be true for TIFF. 47 */ 48 static PSEncoder* newCCITTFaxEncode(GenBuffer::Writable &out_,slendiff_t K, slen_t Columns, bool EndOfLine=false, bool BlackIs1=false); 49 /** PSL2 LZWEncode filter EarlyChange=true, UnitLength=8 LowBitFirst=false */ 50 static PSEncoder* newLZWEncode(GenBuffer::Writable &out_); 51 /** PSL3 FlateEncode (ZIP) filter Effort=...: 1..9: 9==highest compression. -1==5 */ 52 static PSEncoder* newFlateEncode(GenBuffer::Writable &out_, signed Effort=-1); 53 /** PSL2 RunLengthEncode filter, similar to TIFF PackBits, recordsize=... */ 54 static PSEncoder* newRunLengthEncode(GenBuffer::Writable &out_, slen_t RecordSize=0); 55 /** PSL2 DCTEncode. Calls the cjpeg utility (in the debian package 56 * libjpeg-progs) to do the task. The input must be RGB or Gray with 57 * BitsPerComponent==8. 58 */ 59 static PSEncoder* newDCTIJGEncode(GenBuffer::Writable &out_, 60 slen_t Columns, 61 slen_t Rows, 62 unsigned char Colors, /*1..4*/ 63 unsigned char quality /*libJPEG quality: 0..100 */ 64 ); 65 /** @param other_parameters "" or something 66 * like: "/HSamples [1 2 1]/ColorTransform 2" 67 */ 68 static PSEncoder* newDCTEncode(GenBuffer::Writable &out_, 69 slen_t Columns, 70 slen_t Rows, 71 unsigned char Colors, /*1..4*/ 72 unsigned char ColorTransform, /*0,1,2 3=default*/ 73 SimBuffer::Flat const& other_parameters 74 ); 75 /** PSL2 DCTEncode. Not supported yet. Imp: build support */ 76 static PSEncoder* newDCTEncode(GenBuffer::Writable &out_, 77 slen_t Columns, 78 slen_t Rows, 79 unsigned char Colors, /*1..4*/ 80 unsigned char quality=75, /*libJPEG quality: 0..100 */ 81 unsigned char const*HSamples=(unsigned char*)NULLP, /*all 1..4, NULLP OK*/ 82 unsigned char const*VSamples=(unsigned char*)NULLP, /*all 1..4, NULLP OK*/ 83 /* vvv pacify VC6.0; no unsigned char (*QuantTables)[64]=(unsigned char(*)[64])NULLP, */ 84 unsigned char (*QuantTables)[64]=0, /*NULLP OK*/ 85 double QFactor=1.0, /*0..1000000*/ 86 unsigned numHuffTables=0, 87 unsigned char **HuffTables=(unsigned char**)NULLP, /*NULLP OK*/ 88 unsigned char ColorTransform=2 /*0,1,2 3=default*/ 89 ); 90 // static Encoder* newTIFFPredictor2(GenBuffer::Writable &out_, unsigned char bpc_, slen_t columns_, unsigned char cpp_); 91 // static Encoder* newPNGPredictor11(GenBuffer::Writable &out_, unsigned char bpc_, slen_t columns_, unsigned char cpp_); 92 /** @param type: 1: no predictor, 2: TIFFPredictor2, 10: PNGPredictorNone (None) 93 * 11: PNGPredictorSub (Sub), 12: PNGPredictorUp (Up), 94 * 13: PNGPredictorAverage (Average), 14: PNGPredictorPaeth (Paeth), 95 * 15: PNGPredictorAuto (optimum). 96 */ 97 static Encoder* newPredictor(GenBuffer::Writable &out_, unsigned char type, unsigned char bpc_, slen_t columns_, unsigned char cpp_); 98 protected: 99 // char const *longname, *shortname; 100 // SimBuffer::B filter_psname; 101 }; 102 103 #endif /* encoder.hpp */ 104