CxImage简要说明

官方下载地址是:http://www.xdp.it/cximage/

打开工程后可以看到下例这些工程:

- CxImage

- CxImageCrtDll

- CxImageMfcDll

- dome

- domeDll

- jasper

- jbig

- jpeg

- libdcr

- mng

- png

- tiff

- zlib

 

1。首先我们要确定在程序中是希望静态链接还是动态链接,在这里我建议大家使用动态链接,因为这个库有点大,如果使用静态链接的话你的应用程序体积会额外增加1MB多。

 

2。然后确定在MFC中使用还是在CRT环境中使用,这个库专门为你建了这两个工程来创建不同环境中使用的运行时库,跟据你的需求来选择编译CxImageCrtDll还是CxImageMfcDll工程,如果你希望使用静态库链接的话除了这两个工程不需要编译其它的工程都需要编译。并且在引用这个静态库的时候要把这些所有编译过的工程里的*.lib全部拷到你的程里去。

 

3。OK编译完工程后将以下文件拷到你建立的工程里去

先将头文件拷到你的工程里去:

xfile.h、ximacfg.h、ximadef.h、ximage.h、xiofile.h、xmemfile.h

 

使用静态链接需要拷以下文件:

cximage.lib、png.lib、Jpeg.lib、jbig.lib、Tiff.lib、libdcr.lib、jasper.lib、zlib.lib、mng.lib

 

如用动态链接需要拷以下文件:

cximage.lib、cximage.dll

 

4。在你的工程里引用这个库#include "ximage.h"、#pragma comment(lib, "cximage.lib")如果是静态链接拷过来的那些*.lib文件全部要引用进去否则无法链接,在这里有人可能会问既然只包含了"ximage.h"这一个头文件为什么要拷那么多头文件过来呢?这是因为"ximage.h"这个头文件依赖那几个头文件所以必须拷过来。

 

5。现在你就可以使用这个CxImage库了,那我们来加载一幅图片然后将它显示出来吧:

      CxImage  image; // 定义一个CxImage对象

 

      image.Load("Ooopsy.png", CXIMAGE_FORMAT_PNG); // 加载一幅png图片

 

      // 在OnPaint消息里显示出来

      image.Draw(dc.GetSafeHdc(), 0, 0);

 

     以上只介绍最简单的用法,至于基它的功能你就自已尝试,我就不多说了,要是我一下子说完了CxImage开发者就不需要写文档说明了,在它的跟目录下有一个index.htm这就是它的文档起始页,如果你需要的话就自已去看吧!

 

 

 

具体应用技巧

1、打开一张图
可以通过创建一个新的CxImage对象来完成,通过构造函数来打开一张图
CxImage::CxImage(const char * filename, DWORD imagetype)
其中filename是需要打开的文件路径,imagetype是文件类型,支持的类型有:
CXIMAGE_FORMAT_UNKNOWN,CXIMAGE_FORMAT_BMP,CXIMAGE_FORMAT_GIF,CXIMAGE_FORMAT_JPG,CXIMAGE_FORMAT_PNG,CXIMAGE_FORMAT_MNG,CXIMAGE_FORMAT_ICO,CXIMAGE_FORMAT_TIF,CXIMAGE_FORMAT_TGA,CXIMAGE_FORMAT_PCX,CXIMAGE_FORMAT_WBMP,CXIMAGE_FORMAT_WMF,CXIMAGE_FORMAT_J2K,CXIMAGE_FORMAT_JBG,CXIMAGE_FORMAT_JP2,CXIMAGE_FORMAT_JPC,CXIMAGE_FORMAT_PGX,CXIMAGE_FORMAT_PNM,CXIMAGE_FORMAT_RAS,
当然,这么多格式很难记住,我们可以通过如下函数来直接获得文件的格式。
int FindType(const CString& filename)
{
 CString ext = filename.Right(filename.GetLength()-filename.ReverseFind('.')-1);
 int type = 0;
 if (ext == "bmp")     type = CXIMAGE_FORMAT_BMP;
#if CXIMAGE_SUPPORT_JPG
 else if (ext=="jpg"||ext=="jpeg") type = CXIMAGE_FORMAT_JPG;
#endif
#if CXIMAGE_SUPPORT_GIF
 else if (ext == "gif")    type = CXIMAGE_FORMAT_GIF;
#endif
#if CXIMAGE_SUPPORT_PNG
 else if (ext == "png")    type = CXIMAGE_FORMAT_PNG;
#endif
#if CXIMAGE_SUPPORT_MNG
 else if (ext=="mng"||ext=="jng") type = CXIMAGE_FORMAT_MNG;
#endif
#if CXIMAGE_SUPPORT_ICO
 else if (ext == "ico")    type = CXIMAGE_FORMAT_ICO;
#endif
#if CXIMAGE_SUPPORT_TIF
 else if (ext=="tiff"||ext=="tif") type = CXIMAGE_FORMAT_TIF;
#endif
#if CXIMAGE_SUPPORT_TGA
 else if (ext=="tga")    type = CXIMAGE_FORMAT_TGA;
#endif
#if CXIMAGE_SUPPORT_PCX
 else if (ext=="pcx")    type = CXIMAGE_FORMAT_PCX;
#endif
#if CXIMAGE_SUPPORT_WBMP
 else if (ext=="wbmp")    type = CXIMAGE_FORMAT_WBMP;
#endif
#if CXIMAGE_SUPPORT_WMF
 else if (ext=="wmf"||ext=="emf") type = CXIMAGE_FORMAT_WMF;
#endif
#if CXIMAGE_SUPPORT_J2K
 else if (ext=="j2k"||ext=="jp2") type = CXIMAGE_FORMAT_J2K;
#endif
#if CXIMAGE_SUPPORT_JBG
 else if (ext=="jbg")    type = CXIMAGE_FORMAT_JBG;
#endif
#if CXIMAGE_SUPPORT_JP2
 else if (ext=="jp2"||ext=="j2k") type = CXIMAGE_FORMAT_JP2;
#endif
#if CXIMAGE_SUPPORT_JPC
 else if (ext=="jpc"||ext=="j2c") type = CXIMAGE_FORMAT_JPC;
#endif
#if CXIMAGE_SUPPORT_PGX
 else if (ext=="pgx")    type = CXIMAGE_FORMAT_PGX;
#endif
#if CXIMAGE_SUPPORT_RAS
 else if (ext=="ras")    type = CXIMAGE_FORMAT_RAS;
#endif
#if CXIMAGE_SUPPORT_PNM
 else if (ext=="pnm"||ext=="pgm"||ext=="ppm") type = CXIMAGE_FORMAT_PNM;
#endif
 else type = CXIMAGE_FORMAT_UNKNOWN;
 
 return type;
}

2、保存一张图
bool CxImage::Save(LPCWSTR filename, DWORD imagetype=0)
参数和上面是一样的。
3、得到图形数据,以便在OpenGL中使用材质
 BYTE* CxImage::GetBits(DWORD row = 0);
4、得到图形大小
long GetSize();
5、得到图形高度和宽度
 DWORD CxImage::GetHeight();
 DWORD CxImage::GetWidth();
6、得到文件类型
 DWORD CxImage::GetType()  const;
7、得到最后一个错误
 char* CxImage::GetLastError();
8、在界面中绘制出来
long CxImage::Draw(HDC hdc, const RECT& rect, RECT* pClipRect=NULL)
HDC 绘图设备,rect 绘图的区域,确定绘图的左上角和右下角坐标。pClipRect,裁剪区域,一般可以和绘图区域一样大小,除非特殊需要。

 

    

CxImage类库是一个优秀的图像操作类库。它可以快捷地存取、显示、转换各种图像。有的读者可能说,有那么多优秀的图形库,如OpenIL,FreeImage,PaintLib等等,它们可谓是功能强大,齐全,没必要用其它的类库。但我要说,这些类库基本上没有免费的,使用这些类库,你要被这样那样的许可协议所束缚。在这点上,CxImage类库是完全免费的。另外,在使用上述类库时,你会遇到重重麻烦。因为它们大部分是平台无关的,且用C语言写成,有的还夹杂着基本的C++ wrapper和成堆德编译选项的声明需要你去处理。而CxImage类库在这方面做得很好。还有让我最看好的,就是作者完全公开了源代码。相对于那些封装好的图形库和GDI+来说,这一点使我们可以进一步学习各种编解码技术,而不再浮于各种技术的表面。 CxImage类库的结构:

 

一个CxImage对象是一个扩展了的位图。作者只是在位图结构上添加了一些起存储信息作用的成员变量。一个CxImage对象(同时)也是一组层。每个层只有在需要时才会分配相应的缓冲区。CxImage::pDib代表着背景图像,CxImage::pAlpha代表着透明层,CxImage::pSelection代表着被选中的层,被用来创建图像处理时让用户感兴趣的区域。在这三个特殊层面的基础上,你可以增加一些额外的层,这些层可以存储在CxImage::pLayers中。一般说来,层是一个完整的CxImage对象。因此,你可以构造很复杂的嵌套层。下面是CxImage的一些成员变量:

 

  1. class DLL_EXP CxImage  
  2. {  
  3. //extensible information collector   
  4. typedef struct tagCxImageInfo {  
  5.     DWORD   dwEffWidth;         //DWORD aligned scan line width   
  6.     BYTE*   pImage;             //THE IMAGE BITS   
  7.     CxImage* pGhost;            //if this is a ghost, pGhost points to the body   
  8.     CxImage* pParent;           //if this is a layer, pParent points to the body   
  9.     DWORD   dwType;             //original image format   
  10.     char    szLastError[256];   //debugging   
  11.     long    nProgress;          //monitor   
  12.     long    nEscape;            //escape   
  13.     long    nBkgndIndex;        //used for GIF, PNG, MNG   
  14.     RGBQUAD nBkgndColor;        //used for RGB transparency   
  15.     BYTE    nQuality;           //used for JPEG   
  16.     long    nFrame;             //used for TIF, GIF, MNG : actual frame   
  17.     long    nNumFrames;         //used for TIF, GIF, MNG : total number of frames   
  18.     DWORD   dwFrameDelay;       //used for GIF, MNG   
  19.     long    xDPI;               //horizontal resolution   
  20.     long    yDPI;               //vertical resolution   
  21.     RECT    rSelectionBox;      //bounding rectangle   
  22.     BYTE    nAlphaMax;          //max opacity (fade)   
  23.     bool    bAlphaPaletteEnabled; //true if alpha values in the palette are enabled.   
  24.     bool    bEnabled;           //enables the painting functions   
  25.     long    xOffset;  
  26.     long    yOffset;  
  27.     DWORD   dwEncodeOption;     //for GIF, TIF : 0=def.1=unc,2=fax3,3=fax4,4=pack,5=jpg   
  28.     RGBQUAD last_c;             //for GetNearestIndex optimization   
  29.     BYTE    last_c_index;  
  30.     bool    last_c_isvalid;  
  31.     long    nNumLayers;  
  32.     DWORD   dwFlags;            // 0x??00000 = reserved, 0x00??0000 = blend mode, 0x0000???? = layer id - user flags   
  33.   
  34. } CXIMAGEINFO;  
  35.   
  36. public:  
  37.     //constructors   
  38.     CxImage(DWORD imagetype = 0);  
  39.     CxImage(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD imagetype = 0);  
  40.     CxImage(const CxImage &src, bool copypixels = truebool copyselection = truebool copyalpha = true);  
  41.     CxImage(const char * filename, DWORD imagetype);  
  42.     CxImage(FILE * stream, DWORD imagetype);  
  43.     CxImage(CxFile * stream, DWORD imagetype);  
  44.     CxImage(BYTE * buffer, DWORD size, DWORD imagetype);  
  45.     virtual ~CxImage() { Destroy(); };  
  46.     CxImage& operator = (const CxImage&);  
  47.   
  48.     //initializzation   
  49.     void*   Create(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD imagetype = 0);  
  50.     void    Destroy();  
  51.     void    Clear(BYTE bval=0);  
  52.     void    Copy(const CxImage &src, bool copypixels = truebool copyselection = truebool copyalpha = true);  
  53.     void    Transfer(CxImage &from);  
  54.     bool    CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage);  
  55.     bool    CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage);  
  56.   
  57.     //Attributes   
  58.     long    GetSize();  
  59.     BYTE*   GetBits(DWORD row = 0);  
  60.     BYTE    GetColorType();  
  61.     void*   GetDIB()        const {return pDib;}  
  62.     DWORD   GetHeight()     const {return head.biHeight;}  
  63.     DWORD   GetWidth()      const {return head.biWidth;}  
  64.     DWORD   GetEffWidth()   const {return info.dwEffWidth;}  
  65.     DWORD   GetNumColors()  const {return head.biClrUsed;}  
  66.     WORD    GetBpp()        const {return head.biBitCount;}  
  67.     DWORD   GetType()       const {return info.dwType;}  
  68.     char*   GetLastError()  {return info.szLastError;}  
  69.     const char* GetVersion();  
  70.   
  71.     DWORD   GetFrameDelay() const {return info.dwFrameDelay;}  
  72.     void    SetFrameDelay(DWORD d) {info.dwFrameDelay=d;}  
  73.   
  74.     void    GetOffset(long *x,long *y) {*x=info.xOffset; *y=info.yOffset;}  
  75.     void    SetOffset(long x,long y) {info.xOffset=x; info.yOffset=y;}  
  76.   
  77.     BYTE    GetJpegQuality() const {return info.nQuality;}  
  78.     void    SetJpegQuality(BYTE q) {info.nQuality = q;}  
  79.   
  80.     long    GetXDPI()       const {return info.xDPI;}  
  81.     long    GetYDPI()       const {return info.yDPI;}  
  82.     void    SetXDPI(long dpi);  
  83.     void    SetYDPI(long dpi);  
  84.   
  85.     DWORD   GetClrImportant() const {return head.biClrImportant;}  
  86.     void    SetClrImportant(DWORD ncolors = 0);  
  87.   
  88.     long    GetProgress()   const {return info.nProgress;}  
  89.     long    GetEscape()     const {return info.nEscape;}  
  90.     void    SetProgress(long p) {info.nProgress = p;}  
  91.     void    SetEscape(long i)   {info.nEscape = i;}  
  92.   
  93.     long    GetTransIndex() const {return info.nBkgndIndex;}  
  94.     RGBQUAD GetTransColor();  
  95.     void    SetTransIndex(long idx) {info.nBkgndIndex = idx;}  
  96.     void    SetTransColor(RGBQUAD rgb) {rgb.rgbReserved=0; info.nBkgndColor = rgb;}  
  97.     bool    IsTransparent() const {return info.nBkgndIndex>=0;} // <vho>   
  98.   
  99.     DWORD   GetEncodeOption() const {return info.dwEncodeOption;}  
  100.     void    SetEncodeOption(DWORD opt) {info.dwEncodeOption = opt;}  
  101.   
  102.     DWORD   GetFlags() const {return info.dwFlags;}  
  103.     void    SetFlags(DWORD flags, bool bLockReservedFlags = true);  
  104.   
  105.     //void* GetUserData() const {return info.pUserData;}   
  106.     //void  SetUserData(void* pUserData) {info.pUserData = pUserData;}   
  107.   
  108.     //palette operations   
  109.     bool    IsGrayScale();  
  110.     bool    IsIndexed() {return head.biClrUsed!=0;}  
  111.     DWORD   GetPaletteSize();  
  112.     RGBQUAD* GetPalette() const;  
  113.     RGBQUAD GetPaletteColor(BYTE idx);  
  114.     bool    GetPaletteColor(BYTE i, BYTE* r, BYTE* g, BYTE* b);  
  115.     BYTE    GetNearestIndex(RGBQUAD c);  
  116.     void    BlendPalette(COLORREF cr,long perc);  
  117.     void    SetGrayPalette();  
  118.     void    SetPalette(DWORD n, BYTE *r, BYTE *g, BYTE *b);  
  119.     void    SetPalette(RGBQUAD* pPal,DWORD nColors=256);  
  120.     void    SetPalette(rgb_color *rgb,DWORD nColors=256);  
  121.     void    SetPaletteColor(BYTE idx, BYTE r, BYTE g, BYTE b, BYTE alpha=0);  
  122.     void    SetPaletteColor(BYTE idx, RGBQUAD c);  
  123.     void    SetPaletteColor(BYTE idx, COLORREF cr);  
  124.     void    SwapIndex(BYTE idx1, BYTE idx2);  
  125.     void    SetStdPalette();  
  126.   
  127.     //pixel operations   
  128.     bool    IsInside(long x, long y);  
  129.     bool    IsTransparent(long x,long y);  
  130.     RGBQUAD GetPixelColor(long x,long y);  
  131.     BYTE    GetPixelIndex(long x,long y);  
  132.     BYTE    GetPixelGray(long x, long y);  
  133.     void    SetPixelColor(long x,long y,RGBQUAD c, bool bEditAlpha = false);  
  134.     void    SetPixelColor(long x,long y,COLORREF cr);  
  135.     void    SetPixelIndex(long x,long y,BYTE i);  
  136.     void    DrawLine(int StartX, int EndX, int StartY, int EndY, RGBQUAD color, bool bEditAlpha=false);  
  137.     void    DrawLine(int StartX, int EndX, int StartY, int EndY, COLORREF cr);  
  138.   
  139.   
  140.     //painting operations   
  141. #if CXIMAGE_SUPPORT_WINCE   
  142.     long    Blt(HDC pDC, long x=0, long y=0);  
  143. #endif   
  144. #if CXIMAGE_SUPPORT_WINDOWS   
  145.     HBITMAP MakeBitmap(HDC hdc = NULL);  
  146.     HANDLE  CopyToHandle();  
  147.     bool    CreateFromHANDLE(HANDLE hMem);      //Windows objects (clipboard)   
  148.     void    CreateFromHBITMAP(HBITMAP hbmp, HPALETTE hpal=0);   //Windows resource   
  149.     void    CreateFromHICON(HICON hico);  
  150.     long    Draw(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1, RECT* pClipRect = 0);  
  151.     long    Draw(HDC hdc, const RECT& rect, RECT* pClipRect=NULL) { return Draw(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, pClipRect); }  
  152.     long    Stretch(HDC hdc, long xoffset, long yoffset, long xsize, long ysize);  
  153.     long    Stretch(HDC hdc, const RECT& rect) { return Stretch(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); }  
  154.     long    Tile(HDC hdc, RECT *rc);  
  155.     long    Draw2(HDC hdc, long x=0, long y=0, long cx = -1, long cy = -1);  
  156.     long    Draw2(HDC hdc, const RECT& rect) { return Draw2(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); }  
  157.     long    DrawText(HDC hdc, long x, long y, const char* text, RGBQUAD color, const char* font, long lSize=0, long lWeight=400, BYTE bItalic=0, BYTE bUnderline=0, bool bEditAlpha=false);  
  158. #endif //CXIMAGE_SUPPORT_WINDOWS   
  159.   
  160.     // file operations   
  161. #if CXIMAGE_SUPPORT_DECODE   
  162. #ifdef WIN32   
  163.     bool Load(LPCWSTR filename, DWORD imagetype=0);  
  164.     bool LoadResource(HRSRC hRes, DWORD imagetype, HMODULE hModule=NULL);  
  165. #endif   
  166.     bool Load(const char * filename, DWORD imagetype=0);  
  167.     bool Decode(FILE * hFile, DWORD imagetype);  
  168.     bool Decode(CxFile * hFile, DWORD imagetype);  
  169.     bool Decode(BYTE * buffer, DWORD size, DWORD imagetype);  
  170. #endif //CXIMAGE_SUPPORT_DECODE   
  171.   
  172. #if CXIMAGE_SUPPORT_ENCODE   
  173. #ifdef WIN32   
  174.     bool Save(LPCWSTR filename, DWORD imagetype=0);  
  175. #endif   
  176.     bool Save(const char * filename, DWORD imagetype=0);  
  177.     bool Encode(FILE * hFile, DWORD imagetype);  
  178.     bool Encode(CxFile * hFile, DWORD imagetype);  
  179.     bool Encode(CxFile * hFile, CxImage ** pImages, int pagecount, DWORD imagetype);  
  180.     bool Encode(FILE *hFile, CxImage ** pImages, int pagecount, DWORD imagetype);  
  181.     bool Encode(BYTE * &buffer, long &size, DWORD imagetype);  
  182. #endif //CXIMAGE_SUPPORT_ENCODE   
  183.   
  184.     //misc.   
  185.     bool IsValid() const {return pDib!=0;}  
  186.     bool IsEnabled() const {return info.bEnabled;}  
  187.     void Enable(bool enable=true){info.bEnabled=enable;}  
  188.   
  189.     // frame operations   
  190.     long GetNumFrames() const {return info.nNumFrames;}  
  191.     long GetFrame() const {return info.nFrame;}  
  192.     void SetFrame(long nFrame) {info.nFrame=nFrame;}  
  193.   
  194. #if CXIMAGE_SUPPORT_BASICTRANSFORMATIONS   
  195.     bool GrayScale();  
  196.     bool Flip();  
  197.     bool Mirror();  
  198.     bool Negative();  
  199.     bool RotateLeft(CxImage* iDst = NULL);  
  200.     bool RotateRight(CxImage* iDst = NULL);  
  201. #endif //CXIMAGE_SUPPORT_BASICTRANSFORMATIONS   
  202.   
  203. #if CXIMAGE_SUPPORT_TRANSFORMATION   
  204.     // image operations   
  205.     bool Rotate(float angle, CxImage* iDst = NULL);  
  206.     bool Rotate180(CxImage* iDst = NULL);  
  207.     bool Resample(long newx, long newy, int mode = 1, CxImage* iDst = NULL);  
  208.     bool DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD* ppal = 0, DWORD clrimportant = 0);  
  209.     bool IncreaseBpp(DWORD nbit);  
  210.     bool Dither(long method = 0);  
  211.     bool Crop(long left, long top, long right, long bottom, CxImage* iDst = NULL);  
  212.     bool Crop(const RECT& rect, CxImage* iDst = NULL) { return Crop(rect.left, rect.top, rect.right, rect.bottom, iDst); }  
  213.     bool Skew(float xgain, float ygain, long xpivot=0, long ypivot=0);  
  214.     bool Expand(long left, long top, long right, long bottom, RGBQUAD canvascolor, CxImage* iDst = 0);  
  215.     bool Expand(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst = 0);  
  216.     bool Thumbnail(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst = 0);  
  217.   
  218. protected:  
  219.     float b3spline(float x);  
  220. public:  
  221. #endif //CXIMAGE_SUPPORT_TRANSFORMATION   
  222.   
  223. #if CXIMAGE_SUPPORT_DSP   
  224.     bool Contour();  
  225.     bool HistogramStretch();  
  226.     bool HistogramEqualize();  
  227.     bool HistogramNormalize();  
  228.     bool HistogramRoot();  
  229.     bool HistogramLog();  
  230.     long Histogram(long* red, long* green = 0, long* blue = 0, long* gray = 0, long colorspace = 0);  
  231.     bool Jitter(long radius=2);  
  232.     bool Repair(float radius = 0.25f, long niterations = 1, long colorspace = 0);  
  233.     bool Combine(CxImage* r,CxImage* g,CxImage* b,CxImage* a, long colorspace = 0);  
  234.     bool FFT2(CxImage* srcReal, CxImage* srcImag, CxImage* dstReal, CxImage* dstImag, long direction = 1, bool bForceFFT = truebool bMagnitude = true);  
  235.     bool Noise(long level);  
  236.     bool Median(long Ksize=3);  
  237.     bool Gamma(float gamma);  
  238.     bool ShiftRGB(long r, long g, long b);  
  239.     bool Threshold(BYTE level);  
  240.     bool Colorize(BYTE hue, BYTE sat);  
  241.     bool Light(long brightness, long contrast = 0);  
  242.     float Mean();  
  243.     bool Filter(long* kernel, long Ksize, long Kfactor, long Koffset);  
  244.     bool Erode(long Ksize=2);  
  245.     bool Dilate(long Ksize=2);  
  246.     void HuePalette(float correction=1);  
  247.     enum ImageOpType { OpAdd, OpAnd, OpXor, OpOr, OpMask, OpSrcCopy, OpDstCopy, OpSub, OpSrcBlend };  
  248.     void Mix(CxImage & imgsrc2, ImageOpType op, long lXOffset = 0, long lYOffset = 0);  
  249. protected:  
  250.     bool IsPowerof2(long x);  
  251.     bool FFT(int dir,int m,double *x,double *y);  
  252.     bool DFT(int dir,long m,double *x1,double *y1,double *x2,double *y2);  
  253.     bool RepairChannel(CxImage *ch, float radius);  
  254. public:  
  255.     //color conversion utilities   
  256.     bool SplitRGB(CxImage* r,CxImage* g,CxImage* b);  
  257.     bool SplitYUV(CxImage* y,CxImage* u,CxImage* v);  
  258.     bool SplitHSL(CxImage* h,CxImage* s,CxImage* l);  
  259.     bool SplitYIQ(CxImage* y,CxImage* i,CxImage* q);  
  260.     bool SplitXYZ(CxImage* x,CxImage* y,CxImage* z);  
  261.     bool SplitCMYK(CxImage* c,CxImage* m,CxImage* y,CxImage* k);  
  262.     RGBQUAD HSLtoRGB(COLORREF cHSLColor);  
  263.     RGBQUAD RGBtoHSL(RGBQUAD lRGBColor);  
  264.     RGBQUAD HSLtoRGB(RGBQUAD lHSLColor);  
  265.     RGBQUAD YUVtoRGB(RGBQUAD lYUVColor);  
  266.     RGBQUAD RGBtoYUV(RGBQUAD lRGBColor);  
  267.     RGBQUAD YIQtoRGB(RGBQUAD lYIQColor);  
  268.     RGBQUAD RGBtoYIQ(RGBQUAD lRGBColor);  
  269.     RGBQUAD XYZtoRGB(RGBQUAD lXYZColor);  
  270.     RGBQUAD RGBtoXYZ(RGBQUAD lRGBColor);  
  271. #endif //CXIMAGE_SUPPORT_DSP   
  272.     RGBQUAD RGBtoRGBQUAD(COLORREF cr);  
  273.     COLORREF RGBQUADtoRGB (RGBQUAD c);  
  274.   
  275. #if CXIMAGE_SUPPORT_SELECTION   
  276.     //selection   
  277.     bool SelectionClear();  
  278.     bool SelectionCreate();  
  279.     bool SelectionDelete();  
  280.     bool SelectionInvert();  
  281.     bool SelectionAddRect(RECT r);  
  282.     bool SelectionAddEllipse(RECT r);  
  283.     bool SelectionAddPolygon(POINT *points, long npoints);  
  284.     bool SelectionAddColor(RGBQUAD c);  
  285.     bool SelectionAddPixel(int x, int y);  
  286.     bool SelectionCopy(CxImage &from);  
  287.     bool SelectionIsInside(long x, long y);  
  288.     bool SelectionIsValid(){return pSelection!=0;}  
  289.     void SelectionGetBox(RECT& r){memcpy(&r,&info.rSelectionBox,sizeof(RECT));}  
  290.     bool SelectionToHRGN(HRGN& region);  
  291. #endif //CXIMAGE_SUPPORT_SELECTION   
  292.   
  293. #if CXIMAGE_SUPPORT_ALPHA   
  294.     //Alpha   
  295.     void AlphaClear();  
  296.     void AlphaCreate();  
  297.     void AlphaDelete();  
  298.     void AlphaInvert();  
  299.     bool AlphaMirror();  
  300.     bool AlphaFlip();  
  301.     bool AlphaCopy(CxImage &from);  
  302.     bool AlphaSplit(CxImage *dest);  
  303.     void AlphaStrip();  
  304.     void AlphaSet(BYTE level);  
  305.     bool AlphaSet(CxImage &from);  
  306.     void AlphaSet(long x,long y,BYTE level);  
  307.     BYTE AlphaGet(long x,long y);  
  308.     BYTE AlphaGetMax() const {return info.nAlphaMax;}  
  309.     void AlphaSetMax(BYTE nAlphaMax) {info.nAlphaMax=nAlphaMax;}  
  310.     bool AlphaIsValid(){return pAlpha!=0;}  
  311.     BYTE* AlphaGetBits() const {return pAlpha;}  
  312.   
  313.     void AlphaPaletteClear();  
  314.     void AlphaPaletteEnable(bool enable=true){info.bAlphaPaletteEnabled=enable;}  
  315.     bool AlphaPaletteIsEnabled(){return info.bAlphaPaletteEnabled;}  
  316.     bool AlphaPaletteIsValid();  
  317.     bool AlphaPaletteSplit(CxImage *dest);  
  318. #endif //CXIMAGE_SUPPORT_ALPHA   
  319.   
  320. #if CXIMAGE_SUPPORT_LAYERS   
  321.     bool LayerCreate(long position = -1);  
  322.     bool LayerDelete(long position = -1);  
  323.     void LayerDeleteAll();  
  324.     CxImage* GetLayer(long position);  
  325.     CxImage* GetParent() const {return info.pParent;}  
  326.     long GetNumLayers() const {return info.nNumLayers;}  
  327. #endif //CXIMAGE_SUPPORT_LAYERS   
  328.   
  329. protected:  
  330.     void Startup(DWORD imagetype = 0);  
  331.     void CopyInfo(const CxImage &src);  
  332.     void Ghost(CxImage *src);  
  333.     void RGBtoBGR(BYTE *buffer, int length);  
  334.     float HueToRGB(float n1,float n2, float hue);  
  335.     void Bitfield2RGB(BYTE *src, WORD redmask, WORD greenmask, WORD bluemask, BYTE bpp);  
  336.     static int CompareColors(const void *elem1, const void *elem2);  
  337.     bool EncodeSafeCheck(CxFile *hFile);  
  338.   
  339.     void*               pDib; //contains the header, the palette, the pixels   
  340.     BITMAPINFOHEADER    head; //standard header   
  341.     CXIMAGEINFO         info; //extended information   
  342.     BYTE*               pSelection; //selected region   
  343.     BYTE*               pAlpha; //alpha channel   
  344.     CxImage**           pLayers; //generic layers   
  345. };  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值