本文整理汇总了C++中CImage::GetPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ CImage::GetPixel方法的具体用法?C++ CImage::GetPixel怎么用?C++ CImage::GetPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImage
的用法示例。
在下文中一共展示了CImage::GetPixel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShapeWindowFromBitmap
void ShapeWindowFromBitmap(CImage &image,CWnd *pWnd,COLORREF keyColor)
{
pWnd->MoveWindow(0,0,image.GetWidth(),image.GetHeight());
if (!image.IsNull())
{
CRgn crRgn, crRgnTmp;
crRgn.CreateRectRgn(0,0,0,0);
for (int nY = 0; nY <= image.GetHeight(); nY++)
{
int nX = 0;
do
{
while (nX <= image.GetWidth() && image.GetPixel(nX, nY) == keyColor)
nX++;
int iLeftX = nX;
while (nX <= image.GetWidth() && image.GetPixel(nX, nY) != keyColor)
++nX;
crRgnTmp.CreateRectRgn(iLeftX, nY, nX, nY+1);
crRgn.CombineRgn(&crRgn, &crRgnTmp, RGN_OR);
crRgnTmp.DeleteObject();
}while(nX < image.GetWidth());
nX = 0;
}
pWnd->SetWindowRgn(crRgn,TRUE);
crRgn.DeleteObject();
}
}
示例2: OnSrtpEnvironmentbrdf
void CChildView::OnSrtpEnvironmentbrdf()
{
CWaitCursor wait;//在函数执行过程中使鼠标图标变成等待图标
int newX = 256, newY = 256;
CImage tmpimg;
tmpimg.Create(newX, newY, 24, 0);
float NoV, roughness;
float* res = new float[2];
for (int x = 0; x < newX; x++){
NoV = x*1.0f / newX;
for (int y = 0; y < newY; y++){
roughness = y*2.0f / newY;
IntegrateBRDF(res, roughness, NoV);
tmpimg.SetPixelRGB(x, y, (byte)(res[0] * 255), (byte)(res[1] * 255), 0);
}
}
delete[] res;
imgOriginal.Destroy();
imgOriginal.Create(newX, newY, tmpimg.GetBPP());//根据新的大小建立CImage,GetBPP是获取其大小
for (int x = 0; x < newX; x++){
for (int y = 0; y < newY; y++){
imgOriginal.SetPixel(x, y, tmpimg.GetPixel(x, y));
}
}
tmpimg.Destroy();
//刷新显示图像
Invalidate();
UpdateWindow();
}
示例3: DrawItem
//绘画头像
void CExpression::DrawItem(CDC * pDC, int iXPos, int iYPos, bool bSelectec)
{
CExpressionItem * pExpressionItem=GetExpressItem(iYPos*m_wMaxRow+iXPos);
int nFaceIndex = iYPos*m_wMaxRow+iXPos;
if (pExpressionItem!=NULL)
{
if (bSelectec)
{
pDC->FillSolidRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2,
EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(255,255,255));
pDC->Draw3dRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2,
EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(28,57,208),RGB(28,57,208));
}
else
{
pDC->FillSolidRect(iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE/2,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE/2,
EP_PIC_WHIDE+PIC_SPACE,EP_PIC_HIGHT+PIC_SPACE,RGB(255,255,255));
}
//装载图片
TCHAR szFileName[MAX_PATH]=TEXT("");
_snprintf(szFileName,sizeof(szFileName),TEXT("%s\\Face\\%d.gif"),m_szPath, nFaceIndex);
CImage ImageFace;
if ( SUCCEEDED(ImageFace.Load(szFileName) ) )
{
//背景判断
COLORREF rfColor = ImageFace.GetPixel(0,0);
TransparentBlt(pDC->GetSafeHdc(), iXPos*(EP_PIC_WHIDE+PIC_SPACE)+PIC_SPACE,iYPos*(EP_PIC_HIGHT+PIC_SPACE)+PIC_SPACE,
EP_PIC_WHIDE, EP_PIC_HIGHT, ImageFace.GetDC(), 0, 0, EP_PIC_WHIDE, EP_PIC_HIGHT, rfColor);
ImageFace.ReleaseDC();
}
}
return;
}
示例4: main
int main()
{
int a;//use for pause
char readParaFlag;//if read the parameters (network) which have been trained
//char modifyParaFlag;// if the user want to modify the training parameters
bool needTrainningFlag=false;
vector<vector<double> > inSet;
vector<vector<double> > outSet;
vector<vector<double> > testSet;
vector<vector<double> > testoutSet;//use to calculate the hit ratio in test default
vector<vector<double> > selfDefSet;
vector<double> temp_vec;
int sample_num = SAMPLE_NUM;
int test_num = TEST_NUM;
int input_dimension = INPUT_DIMENSION;
int output_dimension = OUTPUT_DIMENSION;
int hidden_layer_neuron_num = HIDDEN_LAYER_NEURON_NUM;
int max_epoch = MAX_EPOCH;
double trainning_speed = TRAINNING_SPEED;
double min_error =MIN_ERROR;
ifstream infile;
ofstream outfile;//to save the parameters
//deal with the trainning data
CImage img;
COLORREF pixel;
int maxY=LENGTH;
int maxX=LENGTH;
int avg;
byte r,g,b;
string path;
char temp_char[10];
string temp_string;
string pathHead="..\\Data\\Train\\";
for (int i=0;i<OUTPUT_DIMENSION;++i){
for (int j=1;j<=SAMPLE_NUM;++j){
temp_string=itoa(j,temp_char,10);//change j to an int
path=pathHead+char('0'+i)+" ("+temp_string+").bmp";
img.Load((char*)path.data());
// maxY=img.GetHeight();
// maxX=img.GetWidth();
for (int x=0;x<maxX;++x){
for (int y=0;y<maxY;++y){
pixel=img.GetPixel(x,y);
r=GetRValue(pixel);
g=GetGValue(pixel);
b=GetBValue(pixel);
avg=(int)((r+g+b)/3);
if (avg>128) temp_vec.push_back(1);
else temp_vec.push_back(0);
}
}
inSet.push_back(temp_vec);
temp_vec.clear();
for (int x=0;x<i;++x) temp_vec.push_back(0);
temp_vec.push_back(1);
for (int x=i+1;x<OUTPUT_DIMENSION;++x) temp_vec.push_back(0);
outSet.push_back(temp_vec);
temp_vec.clear();
img.Destroy();//important!!!!
}
}
//deal with the test data
pathHead="..\\Data\\Test_Default\\";
for (int i=0;i<OUTPUT_DIMENSION;++i){
for (int j=1;j<=TEST_NUM;++j){
temp_string=itoa(j,temp_char,10);//change j to an int
path=pathHead+char('0'+i)+" ("+temp_string+").bmp";
img.Load((char*)path.data());
//maxY=img.GetHeight();
//maxX=img.GetWidth();
for (int x=0;x<maxX;++x){
for (int y=0;y<maxY;++y){
pixel=img.GetPixel(x,y);
r=GetRValue(pixel);
g=GetGValue(pixel);
b=GetBValue(pixel);
avg=(int)((r+g+b)/3);
if (avg>128) temp_vec.push_back(1);
else temp_vec.push_back(0);
}
}
testSet.push_back(temp_vec);
temp_vec.clear();
for (int x=0;x<i;++x) temp_vec.push_back(0);
temp_vec.push_back(1);
for (int x=i+1;x<OUTPUT_DIMENSION;++x) temp_vec.push_back(0);
testoutSet.push_back(temp_vec);
temp_vec.clear();
//.........这里部分代码省略.........
示例5: TransformImage
BOOL TransformImage(const CImage& original,CImage& transformed,CImage& originalProcessed,CImage& transformedProcessed)
{
COMPLEX_NUMBER** data = (COMPLEX_NUMBER**)malloc(sizeof(COMPLEX_NUMBER*)*original.GetHeight());
for(long y = 0; y < original.GetHeight(); ++y)
{
data[y] = (COMPLEX_NUMBER*)malloc(sizeof(COMPLEX_NUMBER)*original.GetWidth());
for(long x = 0; x < original.GetWidth(); ++x)
{
data[y][x].real = ((LONG)GetRValue(original.GetPixel(x,y)) + (LONG)GetGValue(original.GetPixel(x,y)) + (LONG)GetBValue(original.GetPixel(x,y))) / 3.0f;
data[y][x].imag = 0;
}
}
FFT2D(data,original.GetWidth(),original.GetHeight(),1);
if(!transformed.Create(original.GetWidth(),original.GetHeight(),24))
{
for(long y = 0; y < original.GetHeight(); ++y)
free(data[y]);
free(data);
return FALSE;
}
for(long y = 0; y < original.GetHeight(); ++y)
{
for(long x = 0; x < original.GetWidth(); ++x)
{
FLOAT power = sqrtf(data[y][x].real * data[y][x].real + data[y][x].imag * data[y][x].imag);
transformed.SetPixel(x < original.GetWidth()/2 ? original.GetWidth()/2 + x : x - original.GetWidth()/2,y < original.GetHeight()/2 ? original.GetHeight()/2 + y : y - original.GetHeight()/2,RGB(power*128,power*128,power*128));
}
}
///
AmplitudeBandpassFilter(data,original.GetWidth(),original.GetHeight(),0/128.0f,150/128.0f);
//FrequencyBandpassFilter(data,original.GetWidth(),original.GetHeight(),50,100);
///
if(!transformedProcessed.Create(original.GetWidth(),original.GetHeight(),24))
{
for(long y = 0; y < original.GetHeight(); ++y)
free(data[y]);
free(data);
return FALSE;
}
for(long y = 0; y < original.GetHeight(); ++y)
{
for(long x = 0; x < original.GetWidth(); ++x)
{
FLOAT power = sqrtf(data[y][x].real * data[y][x].real + data[y][x].imag * data[y][x].imag);
transformedProcessed.SetPixel(x < original.GetWidth()/2 ? original.GetWidth()/2 + x : x - original.GetWidth()/2,y < original.GetHeight()/2 ? original.GetHeight()/2 + y : y - original.GetHeight()/2,RGB(power*128,power*128,power*128));
}
}
FFT2D(data,original.GetWidth(),original.GetHeight(),-1);
if(!originalProcessed.Create(original.GetWidth(),original.GetHeight(),24))
{
for(long y = 0; y < original.GetHeight(); ++y)
free(data[y]);
free(data);
return FALSE;
}
for(long y = 0; y < original.GetHeight(); ++y)
{
for(long x = 0; x < original.GetWidth(); ++x)
{
FLOAT power = sqrt(data[y][x].real * data[y][x].real + data[y][x].imag * data[y][x].imag);
originalProcessed.SetPixel(x,y,RGB(power,power,power));
}
}
for(long y = 0; y < original.GetHeight(); ++y)
free(data[y]);
free(data);
return TRUE;
}