palutil.h

Go to the documentation of this file.
00001 /*******************************************************************
00002  *
00003  *    DESCRIPTION: PALUTIL.H
00004  *
00005  *    AUTHOR: D.Silva
00006  *
00007  *    HISTORY:    
00008  *
00009  *******************************************************************/
00010 
00011 #pragma once
00012 #include "maxheap.h"
00013 #include <WTypes.h>
00014 
00015 // forward declarations
00016 struct BMM_Color_24;
00017 struct BMM_Color_48;
00018 struct BMM_Color_64;
00019 
00020 
00021 //-- 256 color dithering-----------------------------------------------------
00022 // For packing colors into 256 color paletted representation.
00023 // Create one with NewColorPacker
00031 class ColorPacker: public MaxHeapOperators {
00032    public:
00034          virtual ~ColorPacker() {}
00040       virtual void EnableDither(BOOL onoff)=0;  // default: MAX default
00048       virtual void PropogateErrorBetweenLines(BOOL onoff)=0;  // default ON; 
00058       virtual void PackLine( BMM_Color_64* in, BYTE *out, int w)=0;
00068       virtual void PackLine( BMM_Color_48* in, BYTE *out, int w)=0;
00071       virtual void DeleteThis()=0;
00072    };
00073 
00074 // Get a color packer.  When done, be sure to call its DeleteThis();
00100 UtilExport ColorPacker *NewColorPacker(
00101    int w,            // width of bitmap to be packed
00102    BMM_Color_48 *pal,   // palette to use
00103    int npal,         // number of entries in the palette
00104    BYTE* remap=NULL, // optional remap done at last stage.
00105    BOOL dither = FALSE
00106    );
00107 
00108 //---------------------------------------------------------------------
00109 // Color quantizer, for doing true-color to paletted conversion
00110 //
00118 class Quantizer: public MaxHeapOperators {
00119    public:
00121       virtual ~Quantizer() {}
00125       virtual int AllocHistogram(void)=0;
00140       virtual int Partition(BMM_Color_48 *pal, int palsize, BMM_Color_64 *forceCol)=0;
00148       virtual void AddToHistogram(BMM_Color_64 *image, int npix)=0;  
00156       virtual void AddToHistogram(BMM_Color_48 *image, int npix)=0;  
00164       virtual void AddToHistogram(BMM_Color_24 *image, int npix)=0;  
00167       virtual void DeleteThis()=0;
00168    };
00169 
00170 UtilExport Quantizer *NewQuantizer();
00171