コード例 #1
1
ファイル: StaffSet.cpp プロジェクト: Forlearngit/HallQueFront
BOOL CStaffSetDlg::ShowPhoto(const CString& strPhotoPath, CWnd* pWnd)
{
	
	POSITION pos=m_ListCtr_Staff.GetFirstSelectedItemPosition();
	int index=m_ListCtr_Staff.GetNextSelectedItem(pos);
	SLZStaff staffinfo=m_List_StaffInfo.GetAt(m_List_StaffInfo.FindIndex(index));
	CStatic* picPhoto = (CStatic*)pWnd;
	CDC* pDC = picPhoto->GetWindowDC();
	CRect rect;
	picPhoto->GetClientRect(&rect);
	CImage img;
	if(strPhotoPath.IsEmpty())
	{
		pDC->SelectStockObject(GRAY_BRUSH);
		pDC->FillRect(	
			&rect, pDC->GetCurrentBrush());
		UpdateData(FALSE);
		return FALSE;
	}
	HRESULT hResult = img.Load(strPhotoPath);
	if(FAILED(hResult))
	{
		MessageBox(_T("图片路径错误,导入失败"));
		staffinfo.SetStaffPhoto(_T(""));
		m_ListCtr_Staff.SetItemText(index,4,_T("未配置"));
		m_List_StaffInfo.GetAt(m_List_StaffInfo.FindIndex(index))=staffinfo;
		return FALSE;
	}
	pDC->SetStretchBltMode(STRETCH_HALFTONE);
	img.Draw(pDC->m_hDC, 0, 0, rect.Width(), rect.Height(), 0, 0, img.GetWidth(), img.GetHeight());
	//把图片填充在控件中
	return TRUE;
}
コード例 #2
0
float CTools::DrawToCDC(IplImage* img,CDC* pDC)
{
	CRect rect;
	CImage bkgound;
	float ratio;
	BITMAPINFO bmi;
	BITMAPINFOHEADER* bmih = &(bmi.bmiHeader);
	memset( bmih, 0, sizeof(*bmih));
	IplImage* pImg = cvCreateImage(cvSize(img->width,img->height),IPL_DEPTH_8U,3);

	if ((img->nChannels * img->depth) == 8)
	{
		cvCvtColor(img,pImg,CV_GRAY2RGB);
	}

	if ((img->nChannels * img->depth) == 24)
	{
		cvCopy(img,pImg);
	}
	if ((img->nChannels * img->depth) > 24)
	{
		AfxMessageBox(L"ÇëÊäÈë8BPP»ò24BPPµÄͼÏñ£¡");
		return 0;
	}

	bmih->biSize   = sizeof(BITMAPINFOHEADER);
	bmih->biWidth  = pImg->width;
	bmih->biHeight = -abs(pImg->height);
	bmih->biPlanes = 1;
	bmih->biBitCount = 24;
	bmih->biCompression = BI_RGB;

	pDC->GetWindow()->GetWindowRect(&rect);
	bkgound.Create(rect.Width(),rect.Height(),24);
	if((float)rect.Height()/(pImg->height) > (float)rect.Width()/(pImg->width))
	{
		ratio = (float)rect.Width()/(pImg->width);
		bkgound.Draw(pDC->GetSafeHdc(),0,(int)((pImg->height)*ratio),rect.Width(),rect.Height() - (int)((pImg->height)*ratio));
	}
	else{
		ratio = (float)rect.Height()/(pImg->height);
		bkgound.Draw(pDC->GetSafeHdc(),(int)((pImg->width)*ratio),0,rect.Width() - (int)((pImg->width)*ratio),rect.Height());
	}	
	pDC->SetStretchBltMode(HALFTONE);
	::StretchDIBits(pDC->GetSafeHdc(),0,0,(int)((pImg->width)*ratio),(int)((pImg->height)*ratio),0,0,pImg->width,pImg->height,pImg->imageData,&bmi,DIB_RGB_COLORS,SRCCOPY);
	cvReleaseImage(&pImg);
	return ratio;
} 
コード例 #3
0
// 画图片
void CImageViewDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	if (nIDCtl == m_imageStatic.GetDlgCtrlID())
	{
		CImage buffer;
		buffer.Create(lpDrawItemStruct->rcItem.right - lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top, 32);
		HDC dc = buffer.GetDC();
		SetStretchBltMode(dc, HALFTONE);

		FillRect(dc, &lpDrawItemStruct->rcItem, (HBRUSH)GetStockObject(WHITE_BRUSH));
		CRect rect;
		m_imageStatic.GetWindowRect(rect);
		int yOffset = -m_imageScrollBar.GetScrollPos();
		for (const CImage& i : m_image)
		{
			if (i.IsNull())
				continue;
			SIZE size = GetImageSize(i);
			if (yOffset >= rect.Height())
				break;
			if (yOffset + size.cy > 0)
				i.Draw(dc, 0, yOffset, size.cx, size.cy);

			yOffset += size.cy;
		}
		FrameRect(dc, &lpDrawItemStruct->rcItem, (HBRUSH)GetStockObject(BLACK_BRUSH));

		buffer.ReleaseDC();
		buffer.Draw(lpDrawItemStruct->hDC, 0, 0);
		return;
	}

	CModelessDlg::OnDrawItem(nIDCtl, lpDrawItemStruct);
}
コード例 #4
0
ファイル: faceitemcontrol.cpp プロジェクト: cyrillic7/CPFrom
//绘画头像
VOID CFaceItemControl::DrawFaceOffLine(CDC * pDC, INT nXPos, INT nYPos, INT nWidth, INT nHeight, DWORD dwCustomFace[FACE_CX*FACE_CY])
{
	//创建位图
	CImage ImageCustomFace;
	ImageCustomFace.Create(FACE_CX,FACE_CY,32);

	//获取数据
	INT nImagePitch=ImageCustomFace.GetPitch();
	LPBYTE cbBitCustomFace=(LPBYTE)ImageCustomFace.GetBits();

	//创建区域
	for (INT nYImagePos=0;nYImagePos<FACE_CY;nYImagePos++)
	{
		for (INT nXImagePos=0;nXImagePos<FACE_CX;nXImagePos++)
		{
			//设置颜色
			DWORD dwImageTarget=nYImagePos*nImagePitch+nXImagePos*4L;
			COLORREF crImageTarget=dwCustomFace[nYImagePos*FACE_CX+nXImagePos];

			//提取颜色
			BYTE cbColorR=GetRValue(crImageTarget);
			BYTE cbColorG=GetGValue(crImageTarget);
			BYTE cbColorB=GetBValue(crImageTarget);
			BYTE cbColorGray=(BYTE)(cbColorR*0.30+cbColorG*0.59+cbColorB*0.11);

			//设置颜色
			*(COLORREF *)(cbBitCustomFace+dwImageTarget)=RGB(cbColorGray,cbColorGray,cbColorGray);
		}
	}

	//绘画界面
	ImageCustomFace.Draw(pDC->m_hDC,nXPos,nYPos,nWidth,nHeight);

	return;
}
コード例 #5
0
ファイル: faceitemcontrol.cpp プロジェクト: cyrillic7/CPFrom
//绘画头像
VOID CFaceItemControl::DrawFaceNormal(CDC * pDC, INT nXPos, INT nYPos, INT nWidth, INT nHeight, DWORD dwCustomFace[FACE_CX*FACE_CY])
{
	//创建位图
	CImage ImageCustomFace;
	ImageCustomFace.Create(FACE_CX,FACE_CY,32);

	//获取数据
	INT nImagePitch=ImageCustomFace.GetPitch();
	LPBYTE cbBitCustomFace=(LPBYTE)ImageCustomFace.GetBits();

	//创建区域
	for (INT nYImagePos=0;nYImagePos<FACE_CY;nYImagePos++)
	{
		for (INT nXImagePos=0;nXImagePos<FACE_CX;nXImagePos++)
		{
			//设置颜色
			DWORD dwImageTarget=nYImagePos*nImagePitch+nXImagePos*4L;
			*(COLORREF *)(cbBitCustomFace+dwImageTarget)=dwCustomFace[nYImagePos*FACE_CX+nXImagePos];
		}
	}

	//绘画界面
	ImageCustomFace.Draw(pDC->m_hDC,nXPos,nYPos,nWidth,nHeight);

	return;
}
コード例 #6
0
ファイル: ImageView.cpp プロジェクト: chrisluu/Plugin
void CImageView::OnDraw(CDC* pDC)
{
	CImageDocument* pDoc = GetDocument();
	CImage* pImage = pDoc->GetImage();
	if (pImage)
	{
		pImage->Draw(pDC->GetSafeHdc(), 0, 0);
	}
}
コード例 #7
0
ファイル: IVACloud.cpp プロジェクト: Venvy-dev/OBS
void DrawImage(HWND hParentWnd, CTSTR wszImage, int nResourceID)
{
    CImage *pImage = new CImage;
    pImage->Load(wszImage);
    //pImage->Load(L"D:\\sss.jpg");
    HWND hwndPicZone = GetDlgItem(hParentWnd, nResourceID);
    RECT rect;
    GetClientRect(hwndPicZone, &rect);
    pImage->Draw(GetDC(hwndPicZone), rect);
    delete pImage;
}
コード例 #8
0
ファイル: UIImage.cpp プロジェクト: 9tong/YDWE
	bool CImage::Draw(HDC hDC, CPaintManagerUI* pManager, const RECT& rc, const RECT& rcPaint, const wchar_t* pStrModify) const
	{
		if (!pStrModify)
		{
			return Draw(hDC, pManager, rc, rcPaint);
		}

		CImage temp = *this;
		temp.Parse(pStrModify);
		return temp.Draw(hDC, pManager, rc, rcPaint);
	}
コード例 #9
0
void show_avator(CString strFilePath,CStatic *m_pic)
{
	CImage *pImage = new CImage();
	HRESULT ret = pImage->Load(strFilePath);
	if (FAILED(ret))		return;
	CRect rect;
	m_pic->GetWindowRect(rect);

	CDC* pDC = m_pic->GetWindowDC();
	SetStretchBltMode(pDC->m_hDC, STRETCH_HALFTONE);
	pImage->StretchBlt(pDC->m_hDC, 0, 0, rect.Width(), rect.Height());
	pImage->Draw(pDC->m_hDC, rect);
}
コード例 #10
0
void CInsertDlg::drawpic()
{
	CRect rectPic;
	m_pic.GetClientRect(&rectPic);   //m_picture为Picture Control控件变量,获得控件的区域对象
	CDC* pDC = m_pic.GetWindowDC();    //获得显示控件的DC

	CImage *pImage = new CImage();		//装载图像的类

	int n = all;
	if (cur< n){						//还有图片可以显示
		HRESULT ret;
		CString path = CString(setting.libpath.c_str())
			+ CString("\\") + CString(album.record(fileno[cur]).filename().c_str());
		ret = pImage->Load(path);//从磁盘装载图片,根据页面计算得到的图片下标
		if (FAILED(ret)){
			MessageBox(path + _T("不存在!"));
			return;
		}

		int width = rectPic.Width();	//显示区域的宽和高
		int height = rectPic.Height();

		int picW = pImage->GetWidth();	//图片的宽和高
		int picH = pImage->GetHeight();

		//计算缩放比
		double r1 = double(picW) / double(width);
		double r2 = double(picH) / double(height);

		//r为最优缩放比例
		double r = (r1 >= r2 ? r1 : r2);

		int w = picW / r;
		int h = picH / r;
		int sw = (width - w) / 2;
		int sh = (height - h) / 2;
		//防止缩放后失真
		SetStretchBltMode(pDC->m_hDC, HALFTONE);
		//SetBrushOrgEx(pDC->m_hDC, 0, 0, NULL);
		pImage->StretchBlt(pDC->m_hDC, sw, sh, w, h);

		//显示图片
		pImage->Draw(pDC->m_hDC, sw, sh, w, h);

		ReleaseDC(pDC);
		delete pImage;
	}
	else{
		m_pic.ShowWindow(SW_HIDE);
	}
}
コード例 #11
0
ファイル: SearchDlg.cpp プロジェクト: Karn123/PicManager
void CSearchDlg::drawPicture(CStatic* m_Pic/*控件名称*/, int no/*控件编号0-n-1*/)
{

    	CRect rectPic;
        (*m_Pic).GetClientRect(&rectPic);   
		//m_picture为Picture Control控件变量,获得控件的区域对象
        CDC* pDC = m_Pic->GetWindowDC();    
		//获得显示控件的DC

		CImage *pImage = new CImage();
		//装载图像的类
		
		int pos = currentPage*numInPages+no;
		if (pos< count)
		{ //还有图片可以显示
			pImage->Load(filenames[pos]);//从磁盘装载图片,根据页面计算得到的图片下标
			int width = rectPic.Width();//显示区域的宽和高
			int height =rectPic.Height();
		
			int picW = pImage->GetWidth();//图片的宽和高
			int picH = pImage->GetHeight();
//计算缩放比
			double r1 = double(picW)/double(width);
			double r2 = double(picH)/double(height);
        //r为最优缩放比例
		double r=(r1>=r2?r1:r2);

		//防止缩放后失真
		SetStretchBltMode(pDC -> m_hDC,   HALFTONE);
		SetBrushOrgEx(pDC -> m_hDC,0,0,NULL);
		
		//CPoint RectP = rectPic.CenterPoint();
		//pImage->Draw(pDC->m_hDC,(RectP.x - width/2)+(width - picW / r) / 2, (RectP.y - height / 2)+(height - picH/r) / 2, int(picW / r), int(picH / r));
	//让图片居中
		CPoint RectP = rectPic.CenterPoint();
		pImage->Draw(pDC->m_hDC,(RectP.x - width/2)+(width - picW / r) / 2, (RectP.y - height / 2)+(height - picH/r) / 2, int(picW / r), int(picH / r));
		
        ReleaseDC(pDC); 
		}
		else
		{
		  m_Pic->ShowWindow(SW_HIDE);          
		}

		UpdateData(TRUE);
}		
コード例 #12
0
ファイル: controlClientDlg.cpp プロジェクト: loyoen/Jet
void CcontrolClientDlg::DrawPic(CString filename)
{
	CDialog::OnPaint();
	CImage image; //使用图片类
	image.Load( filename ); //装载路径下图片信息到图片类

	RECT rect = { 0 };
	rect.bottom = image.GetWidth();
	rect.right = image.GetHeight();

	CDC* pDC = GetDlgItem(IDC_PIC)->GetWindowDC();//m_mm.GetWindowDC(); //获得显示控件的DC
	pDC->SetStretchBltMode(STRETCH_HALFTONE); 
	image.Draw( pDC->m_hDC,rect); //图片类的图片绘制Draw函数
	ReleaseDC( pDC ); 
	m_Client.LoadPic(FilePathName);
	//CopyPic();
}
コード例 #13
0
ファイル: UIView.cpp プロジェクト: WU-Dingxiang/XMocker
// Methods(Utilities) - Set Draw Image
void UIView::drawImage(CImage &img, CRect rect, CDC* pDC) {
	TRACE("%s\n", __FUNCTION__);

	// Get Rect
	if (rect.Width()<1 || rect.Height()<1) {
		return;
	}

	// Filter
	if (!img.IsDIBSection()) {
		return; // BackgroundType: None
	}

	// Change Mode - Avoid Twist
	::SetStretchBltMode(*pDC, HALFTONE);
	::SetBrushOrgEx(*pDC, 0, 0, NULL);

	// Draw Background Image 
	img.Draw(pDC->m_hDC, rect); // BackgroundType: Image
}
コード例 #14
0
bool scaleImage(CImage& srcImg,CImage& dstImg,int dstWidth,int dstHeight)
{
	int nHeight = srcImg.GetHeight();
	int nWidth = srcImg.GetWidth();
	
	if(dstImg.CreateEx(dstWidth,dstHeight, 24, BI_RGB))
	{
		HDC ImgDC = dstImg.GetDC();
		int nPreMode = ::SetStretchBltMode(ImgDC,  HALFTONE);
		srcImg.Draw(ImgDC, 0, 0, dstWidth,dstHeight, 0, 0, nWidth, nHeight);
		::SetBrushOrgEx(ImgDC, 0, 0, NULL); 
		::SetStretchBltMode(ImgDC, nPreMode);
		dstImg.ReleaseDC();
	}
	else
	{
		return false;
	}
	return true;
}
コード例 #15
0
//尺度变换
bool Scaling(CImage& srcImg,CImage& dstImg,double ratio)
{
	int nHeight = srcImg.GetHeight();
	int nWidth = srcImg.GetWidth();
	
	if(dstImg.CreateEx((int)(nWidth*ratio),(int)(nHeight*ratio), 24, BI_RGB))
	{
		HDC ImgDC = dstImg.GetDC();
		int nPreMode = ::SetStretchBltMode(ImgDC,  HALFTONE);
		srcImg.Draw(ImgDC, 0, 0, (int)(nWidth*ratio),(int)(nHeight*ratio), 0, 0, nWidth, nHeight);
		::SetBrushOrgEx(ImgDC, 0, 0, NULL); 
		::SetStretchBltMode(ImgDC, nPreMode);
		dstImg.ReleaseDC();
	}
	else
	{
		return false;
	}
	return true;
}
コード例 #16
0
ファイル: Preview.cpp プロジェクト: simonclouds/LatestVersion
void CPreview::SetOnePicBackGnd(LPCTSTR filepath, UINT ID)
{
	CImage image; //创建图片类
	CRect rect;//定义矩形类

	image.Load(filepath); //根据图片路径加载图片
	int cx = image.GetWidth();//获取图片宽度
	int cy = image.GetHeight();//获取图片高度

	GetDlgItem(ID)->GetWindowRect(&rect);//将窗口矩形选中到picture控件上
	ScreenToClient(&rect);//将客户区选中到Picture控件表示的矩形区域内
	GetDlgItem(ID)->MoveWindow(rect.left, rect.top, cx, cy, TRUE);//将窗口移动到Picture控件表示的矩形区域

	CWnd *pWnd=GetDlgItem(ID);//获得pictrue控件窗口的句柄
	pWnd->GetClientRect(&rect);//获得pictrue控件所在的矩形区域
	CDC *pDC=pWnd->GetDC();//获得pictrue控件的DC
	image.Draw(pDC->m_hDC, rect); //将图片画到Picture控件表示的矩形区域

	ReleaseDC(pDC);//释放picture控件的DC
}
コード例 #17
0
void CTransButton::DrawButton(HDC hDestDC)
{
	CRect rc;
	GetClientRect(rc);
	
	int nWindth=rc.Width();
	int nHeight=rc.Height();
	
	HDC hDC=CreateCompatibleDC(hDestDC);//创建兼容DC,采用双缓冲画出	
	HBITMAP hBitmap=CreateCompatibleBitmap(hDestDC,nWindth,nHeight);
	HBITMAP hOldBitmap=(HBITMAP)SelectObject(hDC,hBitmap);

	SetBkMode(hDC,TRANSPARENT);
	//把父窗口的背景图复制到按钮的DC上,实现视觉透明----------------
	CPoint pt(0,0);
	MapWindowPoints(m_pParentWnd,&pt,1);
	if(g_pBackDC)
	{
		BitBlt(hDC,0,0,nWindth,nHeight,g_pBackDC->GetSafeHdc(),
			pt.x,pt.y,SRCCOPY);
	}
	//-------------------------------------------------------------
	HDC hMaskDC=CreateCompatibleDC(hDestDC);
	HBITMAP hMaskBitmap=CreateCompatibleBitmap(hDestDC,nWindth,nHeight);
	HBITMAP hOldMaskBitmap=(HBITMAP)SelectObject(hMaskDC,hMaskBitmap);
	int nAlpha=100;//0--255
	int nOffset=0;
	if (m_BkPic.IsEmpty())
	{
		HBRUSH hbr=CreateSolidBrush(m_bkColor);
		FillRect(hMaskDC,&rc,hbr);
		DeleteObject(hbr);
	}
	else
	{
		CDC *pDC = CDC::FromHandle(hMaskDC);
		CImage img;
		HRESULT hResult = img.Load(m_BkPic);
		if(SUCCEEDED(hResult))
		{
			pDC->SetStretchBltMode(STRETCH_HALFTONE);
			img.Draw(pDC->m_hDC, 0, 0, rc.Width(), rc.Height(), 0, 0, img.GetWidth(), img.GetHeight());
		}
		else
		{
			//加载默认按钮背景图片
			CDoFile doFile;
			CString path = doFile.GetExeFullFilePath();
			path += _T("\\背景\\按钮背景图片.bmp");
			hResult = img.Load(path);
			if(SUCCEEDED(hResult))
			{
				pDC->SetStretchBltMode(STRETCH_HALFTONE);
				img.Draw(pDC->m_hDC, 0, 0, rc.Width(), rc.Height(), 0, 0, img.GetWidth(), img.GetHeight());
			}
			else
			{
				HBRUSH hbr=CreateSolidBrush(m_bkColor);
				FillRect(hMaskDC,&rc,hbr);
				DeleteObject(hbr);
			}
		}
	}

	if(m_bDisable){
		nAlpha=m_nAlpha;
	}else if(m_bDown){
		nAlpha=180;
		nOffset=1;
	}else if(m_bOver){
		nAlpha=150;
	}else{
		nAlpha=m_nAlpha;
	}

	BLENDFUNCTION blend;
	memset( &blend, 0, sizeof( blend) );
	blend.BlendOp= AC_SRC_OVER;
	blend.SourceConstantAlpha= nAlpha; // 透明度 最大255

	HRGN hRgn;
	switch(m_ButtonType)
	{
	case enumRoundRectButton:
		hRgn=CreateRoundRectRgn(0,0,nWindth,nHeight,5,5);
		break;
	case enumRectButton:
		hRgn=CreateRectRgn(0,0,nWindth,nHeight);
		break;
	case enumEllipseButton:
		hRgn=CreateEllipticRgn(0,0,nWindth,nHeight);
		break;
	default:
		break;
	}
	SelectClipRgn (hDC,hRgn);
	//实现透明
	AlphaBlend (hDC,0,0,nWindth,nHeight,hMaskDC,0,0,nWindth,nHeight,blend);
	/////////////
	SelectObject(hMaskDC,hOldMaskBitmap);
	DeleteObject(hMaskBitmap);
	DeleteDC(hMaskDC);
	//////////////显示文字
	CString strText;
	GetWindowText(strText);
	if(strText!=_T(""))
	{
		rc.InflateRect(-2,-2);
		rc.OffsetRect(nOffset,nOffset);
		CFont font;
		font.CreateFontIndirect(&m_lfFont);
		HFONT hOldFont=(HFONT)SelectObject(hDC,font);
		::SetTextColor(hDC,m_textColor);
		::DrawText(hDC,strText,-1,&rc,DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_WORD_ELLIPSIS);
		::SelectObject(hDC,hOldFont);
	}
	SelectClipRgn (hDC,NULL);
	DeleteObject(hRgn);//释放HRGN
	//复制到控件的DC上------------------------
	BitBlt(hDestDC,0,0,nWindth,nHeight,hDC,0,0,SRCCOPY);
	//回收资源
	SelectObject(hDC,hOldBitmap);
	DeleteObject(hBitmap);
	DeleteDC(hDC);
}
コード例 #18
0
ファイル: P1.cpp プロジェクト: Leoyuseu/CodeHub
void CP1::main_do()
{
	

CClientDC dc(this);

//下面是图片路径    
zstringEx imgpath,zs;
imgpath.getCtlText(IDC_EDIT2,this->m_hWnd);
imgpath.trim();
if(imgpath.getStringLen()>0)
{
	if(imgpath[imgpath.getStringLen()-1]!='\\')imgpath+='\\';		
}
//上面是取得图片路径

	        


	//////////////////////////////////////////////按序选文件
	zs=imgpath.v();


	   
		zs+=  face_img_dir[cur_order].name;cur_order++;
		//zs.setCtlText(IDC_EDIT4);
		zs.replaceB(0,".jpg",".bmp");  //如果是JPG文件,暂换为BMP
		zs.replaceB(0,".JPG",".bmp");
		                                 //从按序从枚举数组中取出文件名
	
	
	

	////////////////////////////////////////////按序选文件





	//下面是把JPG转为BMP
	if( !zstringEx::is_file_exist(zs.v())  )
	{
		zs.replaceB(0,".bmp",".jpg");
		if(!zstringEx::is_file_exist(zs.v()))return;

		DRAWPIC.Destroy();
		DRAWPIC.Load(zs.v());
				
		zstringEx zs2;zs2.tools_GetCurDir();
		zs2+="\\jpg2bmp.bmp";  //统一转化为BMP来进行
		DRAWPIC.Save(zs2.v());
		zs=zs2.v();		
	}
	
    DRAWPIC.Destroy();
	DRAWPIC.Load(zs.v());


//if(DRAWPIC.GetWidth()>601)goto loopfor_only_320_small_pic; //大小限制,临时用的



	//下面是把BMP进行缩小,过大的
	if(DRAWPIC.GetWidth()>MY_IMAGE_MAX_WIDTH)
	{
		SMALLPIC.Create(MY_IMAGE_MAX_WIDTH,
			            DRAWPIC.GetHeight()/((float)DRAWPIC.GetWidth()/MY_IMAGE_MAX_WIDTH),
						24);

		HDC hdc=SMALLPIC.GetDC();

		::SetStretchBltMode(hdc,COLORONCOLOR);

		DRAWPIC.Draw(hdc,0,0,SMALLPIC.GetWidth(),SMALLPIC.GetHeight(),0,0,DRAWPIC.GetWidth(),DRAWPIC.GetHeight());
        

		zstringEx zs2;zs2.tools_GetCurDir();
		zs2+="\\cur_small.bmp";  //统一转化为BMP来进行
		SMALLPIC.Save(zs2.v());
        zs=zs2.v();

		SMALLPIC.ReleaseDC();
        SMALLPIC.Destroy();

         DRAWPIC.Destroy();
	     DRAWPIC.Load(zs.v());//重装入
	}



    //下面是把BMP进行缩小,过大的
	if(DRAWPIC.GetHeight()>MY_IMAGE_MAX_HEIGHT)
	{
		SMALLPIC.Create(DRAWPIC.GetWidth()/((float)DRAWPIC.GetHeight()/MY_IMAGE_MAX_HEIGHT),
			            MY_IMAGE_MAX_HEIGHT,
						24);

		HDC hdc=SMALLPIC.GetDC();
        ::SetStretchBltMode(hdc,COLORONCOLOR);
		DRAWPIC.Draw(hdc,0,0,SMALLPIC.GetWidth(),SMALLPIC.GetHeight(),0,0,DRAWPIC.GetWidth(),DRAWPIC.GetHeight());
        

		zstringEx zs2;zs2.tools_GetCurDir();
		zs2+="\\cur_small2.bmp";  //统一转化为BMP来进行
		SMALLPIC.Save(zs2.v());
        zs=zs2.v();

		SMALLPIC.ReleaseDC();
        SMALLPIC.Destroy();

        DRAWPIC.Destroy();
	    DRAWPIC.Load(zs.v());//重装入
	}


	this->RedrawWindow();//去掉原来的
    DRAWPIC.Draw(dc,0,0);//在窗口上画图




 

//1.人脸检测
long zret= zFaceLocate( OID,                     //第一个函数返回的人脸识别实例对象ID
						zs.v(),               //图像文件名,JPG,BMP
						cur_max_out_nums,            //用户要求的最大人脸输出数
						cur_sel_threshold,              //人脸置信度阀值,高于这个阀值才会被输出
						ofs); 
//2.报错信息    
if(zret<0)
{
	char er[256];
	zGetLastError(OID,er);
	AfxMessageBox(er);
}


	//CClientDC dc(this);
   POINT of;of.x=0;of.y=0;
   CString sbwh;
	for(int k=0;k<zret;k++)
	{   		
		//3.标记出选中的人脸
        zFlagFace(OID,(LONG)this->m_hWnd,k,0,0);

		sbwh.Format("E1_W: %d E1_H: %d E2_W: %d E2_H: %d",ofs[k].eye1_w,ofs[k].eye1_h,ofs[k].eye2_w,ofs[k].eye2_h);
        GetDlgItem(6677)->SetWindowText(sbwh);

		//dc.Rectangle(ofs[k].eye1_x-ofs[k].eye1_w/2,
		//	ofs[k].eye1_y-ofs[k].eye1_h/2,
		//	ofs[k].eye1_x+ofs[k].eye1_w/2,
		//	ofs[k].eye1_y+ofs[k].eye1_h/2) ;
		//dc.Rectangle(ofs[k].eye2_x-ofs[k].eye2_w/2,
		//	ofs[k].eye2_y-ofs[k].eye2_h/2,
		//	ofs[k].eye2_x+ofs[k].eye2_w/2,
		//	ofs[k].eye2_y+ofs[k].eye2_h/2) ;
	


		//4.在其下打分
		CString outdf;
		outdf.Format("%d: %0.2f",k+1,ofs[k].tally);
        dc.TextOut(ofs[k].left,ofs[k].bottom,outdf);
		
	}
	 
//5.回收人脸检测内存
    zFaceLocate_FreeMemory(OID);

}//end func
コード例 #19
0
ファイル: Widgie.cpp プロジェクト: prakash028/newscaster
BOOL CWidgieApp::OpenSplashLogo( void )
{
	OutDebugs( "Filling in white the Splash window..." );
	OutDebugs( "Creating Splash window..." );
    /* Display the splash logo Image */
    CRect myRect;
    CDC* dialogDC;
  	/* Display the Slash Dialog */
	m_splash.Create(IDD_SPLASH, NULL);
	m_splash.GetClientRect(&myRect);
    dialogDC = m_splash.GetDC();

#ifdef _DEBUG
	cfgUse2ndMonitor = true;
#endif
   
	if( GetSystemMetrics(SM_CMONITORS) > 1 && cfgUse2ndMonitor )
	{
		int w = GetSystemMetrics(SM_CXFULLSCREEN);
		int y = GetSystemMetrics(SM_CYFULLSCREEN);
		int vw = GetSystemMetrics(SM_CXVIRTUALSCREEN);
		int vy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
		int x2 = vw - w;
		int y2 = vy - y;

		cfgLeft += w;
		cfgRight += x2;
		cfgBottom = vy;
	}

//	Sleep( 10 );		// wait a bit for the window to be ready...
    m_splash.MoveWindow(cfgLeft, cfgTop, cfgRight-cfgLeft, cfgBottom-cfgTop, TRUE);

	// Make the background White
    CBrush bkSplashBrush;
    bkSplashBrush.CreateSolidBrush(0x000000);
    dialogDC->FillRect(&myRect, &bkSplashBrush);

    // load the logo file
    CString fileToShow = cfgLocalBaseDir + cfgLocalImagesDir + cfg_App_LogoFile;
	OutDebugs( "Loading Splash Image - %s", fileToShow.GetBuffer(0) );
	m_splash.ShowWindow( SW_SHOW );

	CImage	SplashLogo;
	if( SplashLogo.Load(fileToShow) != S_OK )
	{
		SplashLogo.LoadFromResource( AfxGetInstanceHandle(), IDB_MAINIMAGE );
	}

	RECT logoRect = { 1,0, 801,600 };
	logoRect.right = cfgRight;
	logoRect.bottom = cfgBottom;
	int showResult;
		
	if( SplashLogo.IsNull() == FALSE )
	{
		OutDebugs( "Showing splash screen..." );
		showResult = SplashLogo.Draw(dialogDC->m_hDC, logoRect);
	}

	PrintTextLarge( "Starting up...." );

	return TRUE;
}
コード例 #20
0
ファイル: DrawWnd.cpp プロジェクト: wyrover/LianLianKan
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;
			HBITMAP hStartBmp=(HBITMAP)LoadImage(m_hinst,TEXT("res\\map\\草2.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>=3600&&tscore<4200)
	{
		for (int i=0;i<5;i++)
		{
			HDC bgDC1 = CreateCompatibleDC(m_hdc);
			BITMAP temBmp;
			HBITMAP hStartBmp=(HBITMAP)LoadImage(m_hinst,TEXT("res\\map\\草2.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>=4200)
	{
		int n=int((tscore-3600)/600);
		for (int i=0;i<n;i++)
		{
			HDC bgDC1 = CreateCompatibleDC(m_hdc);
			BITMAP temBmp;
			HBITMAP hStartBmp=(HBITMAP)LoadImage(m_hinst,TEXT("res\\map\\草3.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);
		}
	}
	BitBlt(m_hdc,0,0,900,600,bgDC,0,0,SRCCOPY);
	DeleteObject(allBitmap);
	DeleteObject(hBrush);
	DeleteDC(bgDC);
	DeleteObject(pen);
}
コード例 #21
0
ファイル: IVACloud.cpp プロジェクト: Venvy-dev/OBS
INT_PTR CALLBACK IVACloudProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_INITDIALOG:
    {
        ConfigIVAInfo *configInfo = (ConfigIVAInfo*)lParam;
        SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)configInfo);
        LocalizeWindow(hwnd);

        HWND hwndPic = GetDlgItem(hwnd, IDC_LISTPIC);
        int i;
        for (i = 0; i < g_pCloudData->m_vIPicDesc.size(); i++)
        {
            std::wstring name;
            StringToWString(g_pCloudData->m_vIPicDesc[i].strTitle, name);

            UINT id = (UINT)SendMessage(hwndPic, LB_ADDSTRING, 0, (LPARAM)name.c_str());
            SendMessage(hwndPic, LB_SETITEMDATA, id, (LPARAM)i);
        }

        CTSTR wszSelPic = configInfo->data->GetString(TEXT("SelCloud"));
        if (wszSelPic != NULL)
        {
            int iNum = SendMessage(hwndPic, LB_FINDSTRINGEXACT, 2, (LPARAM)wszSelPic);
            SendMessage(hwndPic, LB_SETCURSEL, iNum, 0);
            UINT nIndex = (UINT)SendMessage((HWND)hwndPic, LB_GETITEMDATA, iNum, 0);

            std::wstring wstrFilename;
            StringToWString(g_pCloudData->m_vIPicDesc[nIndex].strFileName, wstrFilename);
            DrawImage(hwnd, wstrFilename.c_str(), IDC_PICZONE);
        }

        return 0;
    }

    case WM_COMMAND:
    {
        switch (LOWORD(wParam))
        {
        case IDC_LISTPIC:
        {
            if (HIWORD(wParam) == LBN_SELCHANGE)
            {
                UINT id = (UINT)SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0);
                if (id == LB_ERR)
                    break;
                UINT nIndex = (UINT)SendMessage((HWND)lParam, LB_GETITEMDATA, id, 0);
                std::wstring wstrFilename;
                StringToWString(g_pCloudData->m_vIPicDesc[nIndex].strFileName, wstrFilename);
                DrawImage(hwnd, wstrFilename.c_str(), IDC_PICZONE);
            }
            break;
        }
        case IDTEST:
        {
#if 0
            CImage *img = new CImage;
            HDC dc = GetDC(hwnd);
            img->Load(L"D:\\sss.jpg");
            RECT rect = { 10, 10, 100, 100 };
            img->Draw(GetDC(hwnd), rect);
            delete img;
#endif
            break;
        }
        case IDOK:
        {
            HWND hwndPic = GetDlgItem(hwnd, IDC_LISTPIC);
            UINT id = (UINT)SendMessage((HWND)hwndPic, LB_GETCURSEL, 0, 0);
            if (id == LB_ERR)
            {
                OBSMessageBox(hwnd, L"请选择云图", NULL, 0);
                break;
            }
            UINT nIndex = (UINT)SendMessage((HWND)hwndPic, LB_GETITEMDATA, id, 0);
            ConfigIVAInfo *configInfo = (ConfigIVAInfo*)GetWindowLongPtr(hwnd, DWLP_USER);
            configInfo->data->SetString(TEXT("SelCloud"), g_pCloudData->m_vIPicDesc[nIndex].wstrTitle.c_str());
            configInfo->data->SetInt(TEXT("SelIndex"), nIndex);
        }
        case IDCANCEL:
            EndDialog(hwnd, LOWORD(wParam));
            break;
        }
        break;
    }
    }

    return 0;
}
コード例 #22
-10
ファイル: ciratefiApp.cpp プロジェクト: Ychuan1115/ciratefi
void CiratefiApp::ShowMatOnPicture(Mat& image, CDialog* dlg, int pID)
{

	CRect PictureRect;
	CStatic* PictureControl=(CStatic*)dlg->GetDlgItem(pID);
	PictureControl->GetClientRect(&PictureRect);
	CDC *pDc = PictureControl->GetWindowDC();
	SetStretchBltMode(pDc->m_hDC,STRETCH_HALFTONE);

	Mat resizeImage = image.clone();
	if(resizeImage.rows>PictureRect.Height() || resizeImage.cols>PictureRect.Width())
	{
		double resizeRatio = min((double)PictureRect.Width()/(double)image.cols, (double)PictureRect.Height()/(double)image.rows);
		resize(image, resizeImage, Size(), resizeRatio, resizeRatio);
	}

	CImage outputImage;
	int width = resizeImage.cols;
	int height = resizeImage.rows;
	int channels = resizeImage.channels();
	outputImage.Destroy(); //clear
	outputImage.Create(width, height, 8*channels);

	if(channels==1)
	{
		RGBQUAD* ColorTable;
		int MaxColors=outputImage.GetMaxColorTableEntries();
		ColorTable = new RGBQUAD[MaxColors];
		outputImage.GetColorTable(0, MaxColors, ColorTable);
		for (int i = 0; i < MaxColors; i++)
		{
			ColorTable[i].rgbBlue = (BYTE)i;
			ColorTable[i].rgbGreen = (BYTE)i;
			ColorTable[i].rgbRed = (BYTE)i;
		}
		outputImage.SetColorTable(0, MaxColors, ColorTable);
		delete []ColorTable;
	}


	uchar* ps;
	uchar* pimg = (uchar*)outputImage.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 = outputImage.GetPitch();
	for (int i = 0; i < height; ++i)
	{
		ps = (resizeImage.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];
				}
			}
		}
	}
	outputImage.Draw(pDc->m_hDC, CRect(CPoint(PictureRect.TopLeft().x+(PictureRect.Width()-width)/2,PictureRect.TopLeft().y+(PictureRect.Height()-height)/2), CSize(width,height)));
	dlg->ReleaseDC(pDc);
}