Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

ErrorDiffusionHalftoner.h

Go to the documentation of this file.
00001 /*
00002  * @(#)include/ErrorDiffusionHalftoner.h  1.0  2002-08-27 12:27
00003  *
00004  * Copyright (C)  2002  Daniel Léonard
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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   /* define _ERROR_DIFFUSION_HALFTONER_H_ */

Generated on Sat Sep 7 16:31:37 2002 for Halftoning Library by doxygen1.2.17