00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef INC_MI32_DITHER_H
00032 #define INC_MI32_DITHER_H
00033
00034 #ifndef INC_MI32_COLOR_H
00035 #include <mi32/color.h>
00036 #endif
00037
00038 #ifndef INC_MI32_SIMPLEAR_H
00039 #include <mi32/simplear.h>
00040 #endif
00041
00042 class MISTRING;
00043
00044 class DITHER {
00045 public:
00046
00048 static DITHER* Allocate (
00049 const char* PatternName,
00050 int numcolors,
00051 int cols,
00052 bool bForceMono
00053 );
00054
00057 static const char *GetPatternName (
00058 int num
00059 );
00060
00062 static int GetPatternNum (
00063 const char *name
00064 );
00065
00067 static char **GetPatternList (
00068 int *countp,
00069 bool bAllowErrorDiffusion = true
00070 );
00071
00072 static MISTRING GetPatternLongName (
00073 const char *name
00074 );
00075
00076 virtual ~DITHER();
00077
00081 virtual void DitherSolidColor (
00082 const COLOR& color,
00083 UINT8** out,
00084 int lin,
00085 int col,
00086 int numcols
00087 );
00088
00089 virtual bool CanUseCMYKcm (
00090 ) const {
00091 return false;
00092 };
00093
00100 virtual void DitherSolidColor (
00101 const UINT8 *rgb,
00102 UINT8 **out,
00103 int lin,
00104 int col,
00105 int cols,
00106 UINT32 flags
00107 );
00108
00110 void DitherSolidGray (
00111 UINT8 in,
00112 UINT8* out,
00113 int lin,
00114 int col,
00115 int numcols
00116 ) {
00117 DitherSolidComponent(0, in, out, lin, col, numcols);
00118 }
00119
00128 virtual void DitherLineCMYK (
00129 const UINT8* const* trans,
00130 const UINT8* in,
00131 UINT8** out,
00132 const UINT8* mask,
00133 int lin,
00134 int col,
00135 int NumCols
00136 );
00137
00146 virtual void DitherLineRGB24 (
00147 const UINT8* const* trans,
00148 const UINT8* in,
00149 UINT8** out,
00150 const UINT8* mask,
00151 int lin,
00152 int col,
00153 int NumCols
00154 );
00155
00160 virtual void DitherLineGray (
00161 const UINT8* trans,
00162 const UINT8* in,
00163 UINT8* out,
00164 const UINT8* mask,
00165 int lin,
00166 int col,
00167 int numcols
00168 ) {
00169 DitherComponent(0, trans, in, out, mask, lin, col, numcols, 1);
00170 }
00171
00172
00173
00175 int GetNumLevels (
00176 ) const {
00177 return m_NumLevels;
00178 }
00179
00181 int GetMaxVal (
00182 ) const {
00183 return m_NumLevels - 1;
00184 }
00185
00188 virtual bool HasDotGainCompensation (
00189 ) const {
00190 return (false);
00191 }
00192
00195 virtual bool HasVariableScreenAngle (
00196 ) const {
00197 return (false);
00198 }
00199
00202 virtual bool HasVariableScreenFreq (
00203 ) const {
00204 return (false);
00205 }
00206
00210 virtual void SetDotGain (
00211 int comp,
00212 double size
00213 );
00214
00220 virtual void SetScreenAngle (
00221 int comp,
00222 double angle
00223 );
00224
00230 virtual void SetScreenFreq (
00231 double HalftoneDPI,
00232 double PrinterDPI
00233 );
00234
00239 double ComputeCoverage (
00240 int level,
00241 double DotGain
00242 );
00243
00244 bool SetUseCMYKcm (
00245 bool val = true
00246 ) {
00247 if (!CanUseCMYKcm()) return false;
00248 m_bUseCMYKcm = val;
00249 return (val);
00250 };
00251
00252 protected:
00253
00255 DITHER();
00256
00257 #ifndef GENERATING_DOXYGEN_OUTPUT
00258 virtual void DitherComponent (
00259 int color,
00260 const UINT8* trans,
00261 const UINT8* in,
00262 UINT8* out,
00263 const UINT8* mask,
00264 int lin,
00265 int col,
00266 int numcols,
00267 int step
00268 ) = 0;
00269
00270 virtual void DitherSolidComponent (
00271 int color,
00272 UINT8 in,
00273 UINT8* out,
00274 int lin,
00275 int col,
00276 int numcols
00277 ) = 0;
00278
00279 virtual int Init (
00280 int PatternNum,
00281 int numcolors,
00282 int cols,
00283 bool bForceMono
00284 ) = 0;
00285
00286 void SetNumLevels (
00287 int n
00288 ) {
00289 m_NumLevels = n;
00290 }
00291
00292 bool m_bUseCMYKcm;
00293 #endif
00294
00295 private:
00296 #ifndef GENERATING_DOXYGEN_OUTPUT
00297 static int ReadPatternNames();
00298
00299 int m_NumLevels;
00300 SIMPLE_ARRAY<UINT8> m_TempBuf;
00301 #endif // GENERATING_DOXYGEN_OUTPUT
00302 };
00303
00304
00305
00306 #endif // INC_MI32_DITHER_H