資源簡介
Visual C++.NET圖像處理編程源代碼 陸宗騏,非常使用的代碼,圖像處理經典

代碼片段和文件信息
/******************************************************************
??CreatePal.cpp
??Performing?Color?Quantization?algorithm
******************************************************************/
#include?“stdafx.h“
??
#ifndef _CREATEPAL_C
#define _CREATEPAL_C
typedef?struct?_NODE?
{
????BOOL?bIsLeaf;???????????????//?TRUE?if?node?has?no?children
????UINT?nPixelCount;???????????//?Number?of?pixels?represented?by?this?leaf
????UINT?nRedSum;???????????????//?Sum?of?red?components
????UINT?nGreenSum;?????????????//?Sum?of?green?components
????UINT?nBlueSum;??????????????//?Sum?of?blue?components
????struct?_NODE*?pChild[8];????//?Pointers?to?child?nodes
????struct?_NODE*?pNext;????????//?Pointer?to?next?reducible?node
}?NODE;
void?AddColor?(NODE**?BYTE?BYTE?BYTE?UINT?UINT?UINT*?NODE**);
NODE*?CreateNode?(UINT?UINT?UINT*?NODE**);
void?ReduceTree?(UINT?UINT*?NODE**);
void?DeleteTree?(NODE**);
void?GetPaletteColors?(NODE*?RGBQUAD*?UINT*);
void?TrueColorToIndex(CImage?*pImg0CImage?*pImg1)
{
? struct IMAGEPARAMENT?P;
CImage gpImg;
RGBQUAD ColorTab[256];
HDC hMemDC;
???
GetImageParament(pImg1&P);
? gpImg.Create(P.nWidthP.nHeight80);
?
Create8TreePal(pImg1ColorTab2568);
SetAllPalette(&gpImgColorTab);
hMemDC?=?gpImg.GetDC();
pImg1->BitBlt(hMemDC00P.nWidthP.nHeight00SRCCOPY);
gpImg.ReleaseDC();
ImageCopy(pImg0&gpImg);
gpImg.Destroy();
}
?
//?local?function?to?build?optimal?palette?from?CImage
void?Create8TreePal(CImage?*pImgRGBQUAD?*Pal?UINT?nMaxColors?UINT?nColorBits)
{
struct IMAGEPARAMENT?P;
????int i?j;
????BYTE *pbBits;
????BYTE r?g?b;
????NODE *pTree;
????UINT nLeafCountnIndex;
????NODE *pReducibleNodes[9];
??????
? GetImageParament(pImg&P);
????//?Initialize?octree?variables
????pTree?=?NULL;
????nLeafCount?=?0;
for?(i=0;?i<=(int)?nColorBits;?i++)?pReducibleNodes[i]?=?NULL;
????for?(i=0;?i pbBits?=?(BYTE*)?pImg->GetPixelAddress(0i);
????????for?(j=0;?j ????????????b?=?*pbBits++;
????????????g?=?*pbBits++;
????????????r?=?*pbBits++;
if?(P.nBitCount==32)?pbBits++;
????????????AddColor?(&pTree?r?g?b?nColorBits?0?&nLeafCount
??????????????????????pReducibleNodes);
????????????while?(nLeafCount?>?nMaxColors)
????????????????ReduceTree?(nColorBits?&nLeafCount?pReducibleNodes);
????????}
????}
nIndex?=?0;
????GetPaletteColors?(pTree?Pal?&nIndex);
????DeleteTree?(&pTree);
}
//?local?function?to?add?a?color?to?octree
void?AddColor?(NODE**?ppNode?BYTE?r?BYTE?g?BYTE?b?UINT?nColorBits
????UINT?nLevel?UINT*?pLeafCount?NODE**?pReducibleNodes)
{
????int?nIndex?shift;
????static?BYTE?mask[8]?=?{0x800x400x200x100x080x040x020x01};
????//?If?the?node?doesn‘t?exist?create?it
????if?(*ppNode?==?NULL)
????????*ppNode?=?CreateNode?(nLevel?nColorBits?pLeafCount
??????????????????????????????pReducibleNodes);
????//?Update?color?information?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6339??2005-09-23?12:45??IProcessN\CreatePal.cpp
?????文件????????413??2005-09-01?22:42??IProcessN\CreatePal.h
?????文件???????3315??2005-11-26?20:32??IProcessN\Debug\BuildLog.htm
?????文件??????43218??2005-11-26?20:32??IProcessN\Debug\CreatePal.obj
?????文件??????56508??2005-11-26?20:32??IProcessN\Debug\IProcessB.obj
?????文件??????75064??2005-11-26?20:32??IProcessN\Debug\IProcessC.obj
?????文件?????118874??2005-11-26?20:32??IProcessN\Debug\IProcessD.obj
?????文件??????58425??2005-11-26?20:32??IProcessN\Debug\IProcessE.obj
?????文件??????39793??2005-11-26?20:32??IProcessN\Debug\IProcessF.obj
?????文件????2404352??2005-11-26?20:32??IProcessN\Debug\IProcessN.exe
?????文件????5377496??2005-11-26?20:32??IProcessN\Debug\IProcessN.ilk
?????文件??????28377??2005-11-26?20:32??IProcessN\Debug\IProcessN.obj
?????文件????7449600??2005-11-26?20:32??IProcessN\Debug\IProcessN.pdb
?????文件??????47060??2005-11-26?20:32??IProcessN\Debug\IProcessN.res
?????文件?????283927??2005-11-26?20:32??IProcessN\Debug\IProcessNDoc.obj
?????文件?????407276??2005-11-26?20:32??IProcessN\Debug\IProcessNView.obj
?????文件??????27316??2005-11-26?20:32??IProcessN\Debug\MainFrm.obj
?????文件?????205336??2005-11-26?20:32??IProcessN\Debug\Process.obj
?????文件?????299035??2005-11-26?20:32??IProcessN\Debug\Stdafx.obj
?????文件?????855040??2005-11-26?20:32??IProcessN\Debug\vc70.idb
?????文件?????782336??2005-11-26?20:32??IProcessN\Debug\vc70.pdb
?????文件??????12889??2005-11-26?17:06??IProcessN\IProcessB.cpp
?????文件???????1299??2005-09-27?20:43??IProcessN\IProcessB.h
?????文件??????13875??2005-11-26?17:02??IProcessN\IProcessC.cpp
?????文件????????701??2005-09-27?20:43??IProcessN\IProcessC.h
?????文件??????13570??2009-03-08?23:07??IProcessN\IProcessD.cpp
?????文件???????1012??2005-09-27?20:51??IProcessN\IProcessD.h
?????文件???????9783??2005-11-21?13:50??IProcessN\IProcessE.cpp
?????文件????????584??2005-09-27?20:51??IProcessN\IProcessE.h
?????文件???????3189??2005-09-27?20:51??IProcessN\IProcessF.cpp
............此處省略53個文件信息
評論
共有 條評論