00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00028 #ifndef _ERROR_DIFFUSION_HALFTONER_H_
00029 #define _ERROR_DIFFUSION_HALFTONER_H_
00030
00031 #include "Halftoner.h"
00032
00033 namespace halftoner
00034 {
00035 class ErrorDiffusionSpec;
00036 class Image;
00037
00044 class ErrorDiffusionHalftoner : public Halftoner
00045 {
00046
00047 public:
00052 class PathStrategy
00053 {
00054 protected:
00058 PathStrategy() throw();
00059
00060 public:
00064 virtual ~PathStrategy() throw();
00065
00068
00075 virtual Image* operator()(ErrorDiffusionHalftoner& halftoner, const Image& source, int threshold) throw() = 0;
00077 };
00078
00079 private:
00084 class ScanlinePathStrategy : public ErrorDiffusionHalftoner::PathStrategy
00085 {
00086 public:
00094 Image* operator()(ErrorDiffusionHalftoner& halftoner, const Image& source, int threshold) throw();
00095 };
00096 friend class ErrorDiffusionHalftoner::ScanlinePathStrategy;
00097
00103 class SerpentinePathStrategy : public ErrorDiffusionHalftoner::PathStrategy
00104 {
00105 public:
00113 Image* operator()(ErrorDiffusionHalftoner& halftoner, const Image& source, int threshold) throw();
00114 };
00115 friend class ErrorDiffusionHalftoner::SerpentinePathStrategy;
00116
00119
00120 static ErrorDiffusionHalftoner::ScanlinePathStrategy scan_line_strategy;
00122 static ErrorDiffusionHalftoner::SerpentinePathStrategy serpentine_strategy;
00123
00124 public:
00126 static ErrorDiffusionHalftoner::PathStrategy& SCANLINE;
00128 static ErrorDiffusionHalftoner::PathStrategy& SERPENTINE;
00130
00131 protected:
00135 ErrorDiffusionHalftoner() throw();
00136
00137 public:
00141 virtual ~ErrorDiffusionHalftoner() throw();
00142
00145
00154 Image* halftone(const Image& source, const HalftonerSpec* spec) throw (std::invalid_argument);
00156
00157 protected:
00160
00172 virtual int halftoneToRight(float* source, int i, int j, int offset, int width, int height, int threshold) throw() = 0;
00173
00186 virtual int halftoneToLeft(float* source, int i, int j, int offset, int width, int height, int threshold) throw() = 0;
00188
00189 private:
00192
00199 Image* scanline(const Image& source, int threshold);
00200
00207 Image* serpentine(const Image& source, int threshold);
00209 };
00210
00211 }
00212
00213 #endif