ditherer.hh
上传用户:aoeyumen
上传日期:2007-01-06
资源大小:3329k
文件大小:2k
源码类别:

DVD

开发平台:

Unix_Linux

  1. #ifndef _ditherer_hh_
  2. #define _ditherer_hh_
  3. #include <map>
  4. #include <string>
  5. class Ditherer {
  6. public:
  7.    Ditherer() {_bpp=0;_pixelSize=0;}
  8.    virtual ~Ditherer() {};
  9.    
  10.    virtual void dither(unsigned char * tY,
  11.                        unsigned char * tCr,
  12.                        unsigned char * tCb,
  13.                        unsigned char * dithered_img,
  14.                        int imgWidth,
  15.                        int imgHeight,
  16.                        int viewWidth,
  17.                        int viewHeight,
  18.                        int screenWidth)=0;
  19.    virtual void setBpp(int bpp);
  20.    virtual void setPixelSize(int pixelSize);
  21.    // ditherer modules admin
  22.    static int addModule(class Ditherer * (*alloc)(),string name);
  23.    static Ditherer * allocModule(string name);
  24.    static string getRegisteredModules();
  25.    static void loadDefaultModules();
  26. protected:
  27.    int _bpp;
  28.    int _pixelSize;
  29. private:
  30.    static map<string,Ditherer * (*)()> ditherStore;
  31. };
  32. class GenericDitherer: public Ditherer {
  33. public:
  34.    GenericDitherer();
  35.    virtual ~GenericDitherer();
  36.    virtual void dither(unsigned char * tY,
  37.                        unsigned char * tCr,
  38.                        unsigned char * tCb,
  39.                        unsigned char * dithered_img,
  40.                        int imgWidth,
  41.                        int imgHeight,
  42.                        int viewWidth,
  43.                        int viewHeight,
  44.                        int screenWidth);
  45. protected:
  46.    virtual void  ditherBlock(unsigned char * tY,
  47.                              unsigned char * tCr,
  48.                              unsigned char * tCb,
  49.                              unsigned char * dithered_img,
  50.                              int height,
  51.                              int width,
  52.                              int display_width)=0;
  53. private:
  54.    unsigned char * tempory_Y;
  55.    unsigned char * tempory_Cr;
  56.    unsigned char * tempory_Cb;
  57.    void checking();
  58.    void changeSize(unsigned char * orig,unsigned char * dst,
  59.                    int origXsize,int origYsize,
  60.                    int newXsize, int newYsize);
  61.    void resizeYandDither(unsigned char * tY,
  62.                          unsigned char * tCr,
  63.                          unsigned char * tCb,
  64.                          unsigned char * dithered_img,
  65.                          int origXsize,int origYsize,
  66.                          int newYsize,int screenWidth);
  67. };
  68. #endif