当前位置: 首页>>代码示例>>C++>>正文


C++ CImage::Destroy方法代码示例

本文整理汇总了C++中CImage::Destroy方法的典型用法代码示例。如果您正苦于以下问题:C++ CImage::Destroy方法的具体用法?C++ CImage::Destroy怎么用?C++ CImage::Destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CImage的用法示例。


在下文中一共展示了CImage::Destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HTMLImage

int HTMLImage(EE_Context* pContext, LPRECT lpRect, LPCTSTR lpText)
{
	CFileDialog dlg(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, _T("Image Files(*.jpg;*.jpeg;*.jpe;*.png;*.gif;*.bmp)\0*.jpg;*.jpeg;*.jpe;*.png;*.gif;*.bmp\0All Files(*.*)\0*.*\0\0"));

	if( dlg.DoModal(pContext->hMain)==IDOK )
	{
		int w=-1;
		int h=-1;
		CImage img;
		if( img.Load( dlg.m_szFileName )==S_OK )
		{
			w=img.GetWidth();
			h=img.GetHeight();
			img.Destroy();
		}

		CString strText;
		if( w!=-1 )
			strText.Format(_T("<img src=\"%s\" width=\"%d\" height=\"%d\" border=\"0\" alt=\"$0\">"), dlg.m_szFileName, w, h);
		else
			strText.Format(_T("<img src=\"%s\" width=\"\" height=\"\" border=\"0\" alt=\"$0\">"), dlg.m_szFileName);

		HWND hWnd=(HWND)::SendMessage(pContext->hMain, EEM_GETACTIVETEXT, 0, 0);
		if( hWnd )
			::SendMessage(hWnd, ECM_INSERTSNIPPET, (WPARAM)(LPCTSTR)strText, strText.GetLength());
	}
	return 0;
}
开发者ID:20400992,项目名称:addons,代码行数:28,代码来源:HTMLBar.cpp

示例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();
}
开发者ID:Sylvanuszhy,项目名称:IBL,代码行数:29,代码来源:naiveIBL.cpp

示例3: OnFileSaveAs

void CTreepadView::OnFileSaveAs()
{
	if (!tree.size()) {
		return;
	}
	BOOL isOpen = FALSE;
	CString defaultDir = L"D:\\Treepad\\Iteration";
	CString filter = L"PNG File (*.png)||";
	CString fileName = L"image1.png";         //默认打开的文件名
	CFileDialog openFileDlg(isOpen, L"png", fileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, NULL);
	INT_PTR result = openFileDlg.DoModal();
	CString filePath = defaultDir + "\\" + fileName;
	if (result == IDOK) {
		filePath = openFileDlg.GetPathName();
		CRect rcBk;
		GetClientRect(&rcBk);
		CDC* pDC = GetDC();
		CImage Image;
		Image.Create(rcBk.Width(), rcBk.Height(), 24);
		::BitBlt(Image.GetDC(), 0, 0, rcBk.Width(), rcBk.Height(), pDC->m_hDC, 0, 0, SRCCOPY);
		Image.Save(filePath);
		Image.ReleaseDC();
		Image.Destroy();
	}
	// TODO: 在此添加命令处理程序代码
}
开发者ID:chipon,项目名称:Treepad,代码行数:26,代码来源:TreepadView.cpp

示例4: DrawNormalFace

//绘画头像
void __cdecl CUserFaceRes::DrawNormalFace(CDC * pDC, int nXPos, int nYPos, WORD wFaceID, DWORD dwUserID, DWORD dwCustomFace)
{
	//调整参数
	if (wFaceID>=m_wCount) wFaceID=0;

	//绘画头像
	CDC DCFace;
	DCFace.CreateCompatibleDC(NULL);
	DCFace.SelectObject(m_NormalFace);
	bool bDrawFace = false;
	if(dwCustomFace!=0)
	{
		//头像名称
		CString strDirName;
		strDirName.Format(TEXT("%s\\CustomFace"),m_szDirWork);
		CString strFileName;
		strFileName.Format(TEXT("\\%ld_%d.bmp"), dwUserID, dwCustomFace);

		//读取文件
		CImage FaceImage;
		HRESULT hResult = FaceImage.Load(strDirName + strFileName);
		if (SUCCEEDED(hResult))
		{
			//设置模式
			int nOldBltMode = pDC->SetStretchBltMode(HALFTONE);

			//设置大小
			CRect rcFace;
			rcFace.left = nXPos;
			rcFace.top = nYPos;
			rcFace.right = rcFace.left + m_NormalSize.cx;
			rcFace.bottom = rcFace.top + m_NormalSize.cy;

			//绘画图片
			FaceImage.StretchBlt(pDC->GetSafeHdc(), rcFace);

			//删除资源
			pDC->SetStretchBltMode(nOldBltMode);
			FaceImage.Destroy();

			bDrawFace=true;
		}
	}

	//正常头像
	if(!bDrawFace) 
	{
		m_HeadImage.DrawImage(pDC, nXPos, nYPos, m_NormalSize.cx,m_NormalSize.cy,
			wFaceID*m_NormalSize.cx, 0, m_NormalSize.cx,m_NormalSize.cy);
		//AlphaDrawImage(pDC,nXPos,nYPos,m_NormalSize.cx,m_NormalSize.cy,&DCFace,wFaceID*m_NormalSize.cx,0);
	}

	return;
}
开发者ID:lonyzone,项目名称:oathx-ogrex-editor,代码行数:55,代码来源:UserFaceRes.cpp

示例5: GetWidthHeight

MulRect CPicDlgQuery::GetWidthHeight(const string& path)
{
	CImage img;
	HRESULT hr = img.Load(CCharset::AnsiToUnicode(path).c_str());
	if (hr == S_OK)
	{
		MulRect rect = { 0, 0, img.GetWidth(), img.GetHeight() };
		img.Destroy();
		return rect;
	}
	return MulRect();
}
开发者ID:xylsxyls,项目名称:xueyelingshuang,代码行数:12,代码来源:PicDlgQuery.cpp

示例6: OnBnClickedButtonCapture

void CManualMotionCtlDlg::OnBnClickedButtonCapture()
{
	// TODO: Add your control notification handler code here

	DWORD dwSize;
	
	dwSize=theApp.m_VMRCap.GrabFrame ();
	if(dwSize>0)
	{
		BYTE *pImage;
		theApp.m_VMRCap.GetFrame (&pImage);
		//this->m_ctrlCaptureIMG .ShowImage (pImage);
	}


		int p = 0;
		CImage imageTransparentBack;
		imageTransparentBack.Create(2304, -1296, 24);

		BYTE* memTransparentBack = (BYTE*)imageTransparentBack.GetBits();

		if(dwSize > 0)
		{
			BYTE *pImage;

			dwSize=theApp.m_VMRCap.GetFrame(&pImage);

			for (int y=0;y<1296;y++)
			{
				for (int x=0; x<2304; x++)
				{
					memTransparentBack[p] = pImage[p];
					p++;
					memTransparentBack[p] = pImage[p];
					p++;
					memTransparentBack[p] = pImage[p];
					p++;
				}
			}

			 
			  char buffer [200];
			 // SetSnapshotFileName(buffer);
			  imageTransparentBack.Save("C:\\data\\temp.bmp");
	  
		}

		imageTransparentBack.Destroy();


}
开发者ID:QiangLi3409,项目名称:edge3D_Interactive,代码行数:51,代码来源:ManualMotionCtlDlg.cpp

示例7: OnPaint

//重画函数
void CCardControl::OnPaint()
{
	CPaintDC dc(this);

	//获取位置
	CRect rcClient;
	GetClientRect(&rcClient);

	//加载位图
	CImage ImageBuffer;
	CImageHandle HandleCard(&m_ImageCard);
	CImageHandle HandleFundus(&m_ImageBack);
	ImageBuffer.Create(rcClient.Width(),rcClient.Height(),16);
	if (ImageBuffer.IsNull()==true) return;

	//绘画扑克													                                              
	CDC * pBufferDC=CDC::FromHandle(ImageBuffer.GetDC());

     if(bDrawCard)																	               //add
     {																							   //add
	     for (int i=0;i<m_CardDataArray.GetCount();i++)				   				     
	     {
		   
			 BYTE bCardData=m_CardDataArray[i];
			 m_ImageCard.AlphaDrawImage(pBufferDC,i*CARD_SPACE,0,CARD_WIDTH,CARD_HEIGHT,GetCardXPos(bCardData),GetCardYPos(bCardData),RGB(255,0,255)); //非常好的画图函数
	     }
		    
	 }
    /////////////////////////////////////////////////////////////////////////////////////////begin add
     else																			
     {
		 
	    for(int i=0;i<m_CardDataArray.GetCount();i++)
	    {
			m_ImageBack.AlphaDrawImage(pBufferDC,i*CARD_SPACE,0,CARD_WIDTH,CARD_HEIGHT,3*CARD_WIDTH,4*CARD_HEIGHT,RGB(255,0,255));     //画扑克背面
		}
	 }
    ///////////////////////////////////////////////////////////////////////////////////////////end add
	ImageBuffer.ReleaseDC();
	ImageBuffer.BitBlt(dc,0,0);

	//清理资源
	ImageBuffer.Destroy();

   	return;
}
开发者ID:275958081,项目名称:netfox,代码行数:47,代码来源:CardControl.cpp

示例8: SaveImageToFile

void CTracer::SaveImageToFile(std::string fileName)
{
	CImage image;

	int width = m_camera.m_resolution.x;
	int height = m_camera.m_resolution.y;

	image.Create(width, height, 24);

	int pitch = image.GetPitch();
	unsigned char* imageBuffer = (unsigned char*)image.GetBits();

	if (pitch < 0)
	{
		imageBuffer += pitch * (height - 1);
		pitch = -pitch;
	}

	int i, j;
	int imageDisplacement = 0;
	int textureDisplacement = 0;

	for (i = 0; i < height; i++)
	{
		for (j = 0; j < width; j++)
		{
			glm::vec3 color = m_camera.m_pixels[textureDisplacement + j];

			// clamp(val, minVal, maxVal) = min(max(x, minVal), maxVal)
			// shows that val is in [minVal, maxVal]
			imageBuffer[imageDisplacement + j * 3] = unsigned(glm::clamp(color.b, 0.0f, 1.0f) * 255.0f);
			imageBuffer[imageDisplacement + j * 3 + 1] = unsigned(glm::clamp(color.g, 0.0f, 1.0f) * 255.0f);
			imageBuffer[imageDisplacement + j * 3 + 2] = unsigned(glm::clamp(color.r, 0.0f, 1.0f) * 255.0f);
		}

		imageDisplacement += pitch;
		textureDisplacement += width;
	}

	image.Save(fileName.c_str());
	image.Destroy();
}
开发者ID:seva100,项目名称:blackhole-simulation,代码行数:42,代码来源:Tracer.cpp

示例9: MatToCImage

void CTraffic_Camera_Image::MatToCImage(Mat &mat, CImage &cImage)
{
//create new CImage  
int width    = mat.cols;  
int height   = mat.rows;  
int channels = mat.channels();  
	
//cImage.ReleaseDC();
//cImage.ReleaseGDIPlus();
cImage.Destroy(); //clear  
cImage.Create(width,   
              height, //positive: left-bottom-up   or negative: left-top-down  
              8*channels ); //numbers of bits per pixel  

 //copy values  
uchar* ps;  
uchar* pimg = (uchar*)cImage.GetBits(); //A pointer to the bitmap buffer  
          
    //The pitch is the distance, in bytes. represent the beginning of   
    // one bitmap line and the beginning of the next bitmap line  
    int step = cImage.GetPitch();  

	for (int i = 0; i < height; ++i)  
	{  
        ps = (mat.ptr<uchar>(i));  
        for ( int j = 0; j < width; ++j )  
        {  
            if ( channels == 1 ) //gray  
            {  
                *(pimg + i*step + j) = ps[j];  
            }  
            else if ( channels == 3 ) //color  
            {  
                for (int k = 0 ; k < 3; ++k )  
                {  
                    *(pimg + i*step + j*3 + k ) = ps[j*3 + k];  
                }             
            }  
        }     
    }  

}
开发者ID:miaozhendaoren,项目名称:ygomi_vscpp,代码行数:42,代码来源:Traffic_Camera_Image.cpp

示例10: ReadImage

// 从内存加载图片
BOOL ReadImage(const BYTE* buffer, ULONG size, CImage& img)
{
	// 创建流
	HGLOBAL m_hMem = GlobalAlloc(GMEM_FIXED, size);
	BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
	if (pmem == NULL)
		return FALSE;
	memcpy(pmem, buffer, size);
	IStream* pstm;
	CreateStreamOnHGlobal(m_hMem, FALSE, &pstm);

	// 加载到CImage
	if (!img.IsNull())
		img.Destroy();
	img.Load(pstm);
	
	// 释放流
	GlobalUnlock(m_hMem);
	pstm->Release();
	return !img.IsNull();
}
开发者ID:PlutoLuna,项目名称:TiebaManager,代码行数:22,代码来源:ScanImage.cpp

示例11: DrawCustomBigFace

//绘画头像
void __cdecl CUserFaceRes::DrawCustomBigFace(CDC * pDC, int nXPos, int nYPos, DWORD dwUserID, DWORD dwCustomFace,UINT nWidth,UINT nHeight)
{
	ASSERT(dwUserID!=0 && dwCustomFace!=0);
	if(!(dwUserID!=0 && dwCustomFace!=0))return;

	//头像名称
	CString strDirName;
	strDirName.Format(TEXT("%s\\CustomFace"),m_szDirWork);
	CString strFileName;
	strFileName.Format(TEXT("\\%ld_%d.bmp"), dwUserID, dwCustomFace);

	//读取文件
	CImage FaceImage;
	HRESULT hResult = FaceImage.Load(strDirName + strFileName);
	if (SUCCEEDED(hResult))
	{
		//设置模式
		int nOldBltMode = pDC->SetStretchBltMode(HALFTONE);

		//设置大小
		CRect rcFace;
		rcFace.left = nXPos;
		rcFace.top = nYPos;
		rcFace.right = rcFace.left + nWidth;
		rcFace.bottom = rcFace.top + nHeight;

		//绘画图片
		FaceImage.StretchBlt(pDC->GetSafeHdc(), rcFace);

		//删除资源
		pDC->SetStretchBltMode(nOldBltMode);
		FaceImage.Destroy();
	}

	return;
}
开发者ID:anyboo,项目名称:project,代码行数:37,代码来源:UserFaceRes.cpp

示例12: draw_game_face

void CDrawWnd::draw_game_face(HWND hWnd,int TimeLength,int score)
{
	HDC hdc;
	hdc = GetDC(hWnd);
	HDC bgDC = CreateCompatibleDC(m_hdc);
	RECT rect;
	GetClientRect(hWnd,&rect);
	HBITMAP allBitmap = CreateCompatibleBitmap(hdc,rect.right - rect.left,
			rect.bottom - rect.top);
	SelectObject(bgDC, allBitmap);
	HBRUSH hBrush = CreateSolidBrush(RGB(255,255,255));
	SelectObject(bgDC,hBrush);
	Rectangle(bgDC,rect.left,rect.top,rect.right,rect.bottom);
	CImage image;
	image.Load( _T("res\\map\\游戏.bmp"));
	image.Draw(bgDC,0,0,image.GetWidth(),image.GetHeight());
	image.Destroy(); //释放image

	HPEN hPen1,hPen2,pen;
	pen = CreatePen(PS_SOLID,3,RGB(255,255,0));
	SelectObject(bgDC,pen);
	MoveToEx(bgDC,(a * 40 + 60),(b * 40 + 60),NULL);
	LineTo(bgDC,(c * 40 + 60),(d * 40 + 60));
	MoveToEx(bgDC,(e * 40 + 60),(f * 40 + 60),NULL);
	LineTo(bgDC,(g * 40 + 60),(h * 40 + 60));
	MoveToEx(bgDC,(aa * 40 + 60),(bb * 40 + 60),NULL);
	LineTo(bgDC,(cc * 40 + 60),(dd * 40 + 60));
	a = 0,b = 0,c = 0,d = 0,e = 0,f = 0,g = 0,h = 0,aa = 0,bb = 0,cc = 0,dd = 0;
	hPen2 = CreatePen(PS_NULL, 1, RGB(0, 0, 0));   //画笔 
	SelectObject(bgDC, hPen2); 
    hBrush = CreateSolidBrush(RGB(211, 211, 211)); //实心画刷 灰色
	SelectObject(bgDC, hBrush); 
	Rectangle(bgDC, 100, 20,640, 50); 

	hPen1 = CreatePen(PS_NULL, 1, RGB(0, 0, 0));   //画笔 
	SelectObject(bgDC, hPen1); 
	if(TimeLength>=20)
		hBrush = CreateSolidBrush(RGB(0, 128, 0)); //实心画刷 绿色
	else
		hBrush = CreateSolidBrush(RGB(255, 0, 0));////实心画刷 红色
	SelectObject(bgDC, hBrush); 
	Rectangle(bgDC, 100, 20,100+TimeLength*3, 50); 

	for (int iRow=0;iRow<12;iRow++)
	{
		for (int iCol=0;iCol<16;iCol++)
		{
			if(m_PicPos[iRow][iCol]!=0)
			{
				HDC memDC = CreateCompatibleDC(m_hdc);
				const TCHAR *p= m_pBmpPath[m_PicPos[iRow][iCol]-1];
				HBITMAP hh=(HBITMAP)LoadImage(m_hinst,p,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
				SelectObject(memDC,hh);

				CImage image;
				image.Load( p);
				image.Draw(memDC,0,0,image.GetWidth(),image.GetHeight());

				BitBlt(bgDC,40+iCol*40,40+iRow*40,40,40,memDC,0,0,SRCCOPY);
				DeleteObject(hh);
				DeleteDC(memDC);
			}
		}
	}

	int tscore=score;
	int tem=int(tscore/200);
	if(tscore>=1200)
		tem=0;
	for(int i=0;i<tem;i++)
	{
		HDC bgDC1 = CreateCompatibleDC(m_hdc);
		BITMAP temBmp;
		HBITMAP hStartBmp=(HBITMAP)LoadImage(m_hinst,TEXT("res\\map\\草1.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
		::GetObject(hStartBmp,sizeof(temBmp),&temBmp);
		SelectObject(bgDC1,hStartBmp);
		TransparentBlt(bgDC,120+i*60,500,60,60,bgDC1,0,0,temBmp.bmWidth,temBmp.bmHeight,RGB(255,255,255));
		DeleteObject(hStartBmp);
		//DeleteDC(bgDC);
	}
	if(tscore>=1200&&tscore<1600)
	{
		for(int i=0;i<6;i++)
		{
			HDC bgDC1 = CreateCompatibleDC(m_hdc);
			BITMAP temBmp;
			HBITMAP hStartBmp=(HBITMAP)LoadImage(m_hinst,TEXT("res\\map\\草1.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
			::GetObject(hStartBmp,sizeof(temBmp),&temBmp);
			SelectObject(bgDC1,hStartBmp);
			TransparentBlt(bgDC,120+i*60,500,60,60,bgDC1,0,0,temBmp.bmWidth,temBmp.bmHeight,RGB(255,255,255));
			DeleteObject(hStartBmp);
		}
	}
	if(tscore>=1600&&tscore<3600)
	{
		int n=int((tscore-1200)/400);
		for (int i=0;i<n;i++)
		{
			HDC bgDC1 = CreateCompatibleDC(m_hdc);
			BITMAP temBmp;
//.........这里部分代码省略.........
开发者ID:wyrover,项目名称:LianLianKan,代码行数:101,代码来源:DrawWnd.cpp

示例13: OnEraseBkgnd

//绘画背景
BOOL CUserInfoView::OnEraseBkgnd(CDC * pDC)
{
	//获取位置
	CRect rcClient;
	GetClientRect(&rcClient);

	//建立缓冲
	CImage ImageBuffer;
	ImageBuffer.Create(rcClient.Width(),rcClient.Height(),24);

	//创建 DC
	CDC BufferDC;
	BufferDC.CreateCompatibleDC(pDC);
	BufferDC.SelectObject(ImageBuffer);

	//加载资源
	CImageHandle HandleTitleL(&m_ImageTitleL);
	CImageHandle HandleTitleM(&m_ImageTitleM);
	CImageHandle HandleTitleR(&m_ImageTitleR);

	//绘画背景
	m_ImageTitleL.BitBlt(BufferDC,0,0);

	//填充中间
	for (INT nXPos=m_ImageTitleL.GetWidth();nXPos<rcClient.Width();nXPos+=m_ImageTitleM.GetWidth())
	{
		m_ImageTitleM.BitBlt(BufferDC,nXPos,0);
	}

	//绘画背景
	m_ImageTitleR.BitBlt(BufferDC,rcClient.Width()-m_ImageTitleR.GetWidth(),0);

	//设置 DC
	BufferDC.SetTextColor(CR_TEXT);
	BufferDC.SetBkMode(TRANSPARENT);
	BufferDC.SelectObject(&CSkinAttribute::m_DefaultFont);

	//用户信息
	if (m_bShowInfo==true)
	{
		//变量定义
		tagGlobalUserData & GlobalUserInfo=g_GlobalUnits.GetGolbalUserData();

		//用户头像
		g_GlobalUnits.m_UserFaceRes->DrawNormalFace(&BufferDC,9,8,GlobalUserInfo.wFaceID);

		//构造位置
		TCHAR szBuffer[128]=TEXT("");
		CRect rcAccounts(50,11,rcClient.Width()-20,23);
		CRect rcUnderWrite(50,28,rcClient.Width()-20,40);

		//用户帐号
		_sntprintf(szBuffer,CountArray(szBuffer),TEXT("用户帐号:%s [ %ld ]"),GlobalUserInfo.szAccounts,GlobalUserInfo.dwGameID);
		BufferDC.DrawText(szBuffer,lstrlen(szBuffer),&rcAccounts,DT_VCENTER|DT_WORD_ELLIPSIS|DT_SINGLELINE);

		//个性签名
		_sntprintf(szBuffer,CountArray(szBuffer),TEXT("个性签名:%s"),GlobalUserInfo.szUnderWrite);
		BufferDC.DrawText(szBuffer,lstrlen(szBuffer),&rcUnderWrite,DT_VCENTER|DT_WORD_ELLIPSIS|DT_SINGLELINE);
	}

	//绘画界面
	pDC->BitBlt(0,0,rcClient.Width(),rcClient.Height(),&BufferDC,0,0,SRCCOPY);

	//清理资源
	BufferDC.DeleteDC();
	ImageBuffer.Destroy();

	return TRUE;
}
开发者ID:codercold,项目名称:whgame,代码行数:70,代码来源:UserInfoView.cpp

示例14: 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();
//.........这里部分代码省略.........
开发者ID:weehowe-z,项目名称:Backup,代码行数:101,代码来源:Character+Recognition.cpp

示例15: DrawNormalFace

//绘画头像
void __cdecl CUserFaceRes::DrawNormalFace(CDC * pDC, int nXPos, int nYPos, WORD wFaceID, DWORD dwUserID, DWORD dwCustomFace,DWORD X,DWORD Y)
{
	//调整参数
	if (wFaceID>=m_wCount) wFaceID=0;

	//绘画头像
	CDC DCFace;
	DCFace.CreateCompatibleDC(NULL);
	DCFace.SelectObject(m_NormalFace);

	//////////////////////////////////////////////////////////////////////////
	CDC DCFaceGril;
	DCFaceGril.CreateCompatibleDC(NULL);
	DCFaceGril.SelectObject(m_FaceGirl);

	CDC DCFaceBoby;
	DCFaceBoby.CreateCompatibleDC(NULL);
	DCFaceBoby.SelectObject(m_FaceBoby);
	//////////////////////////////////////////////////////////////////////////

	bool bDrawFace = false;
	if(dwCustomFace!=0)
	{
		//头像名称
		CString strDirName;
		strDirName.Format(TEXT("%s\\CustomFace"),m_szDirWork);
		CString strFileName;
		strFileName.Format(TEXT("\\%ld_%d.bmp"), dwUserID, dwCustomFace);

		//读取文件
		CImage FaceImage;
		HRESULT hResult = FaceImage.Load(strDirName + strFileName);
		if (SUCCEEDED(hResult))
		{
			//设置模式
			int nOldBltMode = pDC->SetStretchBltMode(HALFTONE);

			//设置大小
			CRect rcFace;
			rcFace.left = nXPos;
			rcFace.top = nYPos;
			rcFace.right = rcFace.left + m_NormalSize.cx;
			rcFace.bottom = rcFace.top + m_NormalSize.cy;

			//绘画图片
			FaceImage.StretchBlt(pDC->GetSafeHdc(), rcFace);

			//删除资源
			pDC->SetStretchBltMode(nOldBltMode);
			FaceImage.Destroy();

			bDrawFace=true;
		}
	}

	//正常头像
	if(!bDrawFace) 
	{

		//m_NormalFace.StretchBlt(pDC->GetSafeHdc(), nXPos, nYPos, 32, 32, 0,0,0,0);
		AlphaDrawImage(pDC,nXPos,nYPos,m_NormalSize.cx,m_NormalSize.cy,&DCFace,wFaceID*m_NormalSize.cx,0,X, Y);

// 		//设置大小
// 		CRect rcFace;
// 		rcFace.left = nXPos;
// 		rcFace.top = nYPos;
// 		rcFace.right = rcFace.left + X;
// 		rcFace.bottom = rcFace.top + Y;
// 
// 		if(wFaceID==0)
//  		{
// 			//头像名称
// 			CSize szFace = CSize(X,Y);
// 			AlphaDrawImage(pDC,nXPos,nYPos,szFace.cx,szFace.cy,&DCFaceGril,0,0);
// 
//  		}else
// 		{
// 		  	//头像名称
// 			CSize szFace = CSize(X,Y);
// 			AlphaDrawImage(pDC,nXPos,nYPos,szFace.cx,szFace.cy,&DCFaceBoby,0,0);
// 		//	m_FaceBoby.AlphaDrawImage(pDC, nXPos, nYPos, RGB(255,0,255));
// 		}
		
	}

	return;
}
开发者ID:anyboo,项目名称:project,代码行数:88,代码来源:UserFaceRes.cpp


注:本文中的CImage::Destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。