コード例 #1
0
BOOL CNCaptureView::Initialize()
{
	BOOL bRet = FALSE;
	if (m_brBackground.m_hBrush)
	{
		API_VERIFY(m_brBackground.DeleteObject());
	}

	CWindowDC dcOwner(m_hWnd);
	CDC dcMemory;
	dcMemory.CreateCompatibleDC(dcOwner);

	SilverlightCpp::ZipManager* pZipManager = SilverlightCpp::ZipManager::get_Current();
	FTLASSERT(pZipManager); 

	CBitmap bmpBackGround;
	CImage* pImgBgPattern  = pZipManager->LoadCImage(_T("/Assets/Images/Main/CaptureView/bg_pattern.png")); // NS
	FTLASSERT(pImgBgPattern);
	if (pImgBgPattern)
	{
		bmpBackGround.CreateCompatibleBitmap(dcOwner, pImgBgPattern->GetWidth(), pImgBgPattern->GetHeight());
		CBitmapHandle holdBitmap = dcMemory.SelectBitmap(bmpBackGround);
		API_VERIFY(pImgBgPattern->BitBlt(dcMemory, 0, 0, SRCCOPY));
		m_brBackground.CreatePatternBrush(bmpBackGround);
		dcMemory.SelectBitmap(holdBitmap);
	}
	//else
	//{
	//	bmpBackGround.CreateCompatibleBitmap(dcOwner, 10, 10);
	//	dcMemory.FillSolidRect(0, 0, 5, 5, IMAGE_BACKGROUND_LTGRAY_COLOR);
	//	dcMemory.FillSolidRect(0, 5, 5, 5, IMAGE_BACKGROUND_GRAY_COLOR);
	//	dcMemory.FillSolidRect(5, 0, 5, 5, IMAGE_BACKGROUND_GRAY_COLOR);
	//	dcMemory.FillSolidRect(5, 5, 5, 5, IMAGE_BACKGROUND_LTGRAY_COLOR);
	//}

	//CImage* pDefaultImage = pZipManager->LoadCImage(_T("/Assets/Images/Main/CaptureView/bg_default_img.png")); // NS
	//FTLASSERT(pDefaultImage);
	//if (pDefaultImage)
	//{
	//	m_pDefaultImage = new NDGraphics::CGDIPImage;
	//	m_pDefaultImage->Load(pDefaultImage, ImageFormatPNG);
	//	//API_VERIFY(m_canvasDefaultImage.Create(NULL, m_pDefaultImage->GetWidth(), m_pDefaultImage->GetHeight(), 32));
	//}

	m_strMousePosInfo = CStringResouceMgr::Instance()->GetStringData(TEXT("NCAPTURE_IMAGE_INFO")).c_str();
	m_strMouseSelectInfo = CStringResouceMgr::Instance()->GetStringData(TEXT("NCAPTURE_IMAGE_SELECT_INFO")).c_str();

	_EventHook();

	//API_VERIFY( NULL != m_brBackGround.CreateHatchBrush(HS_CROSS, RGB(127,127,127)));
	m_bInited = TRUE;
	//CRect rcClient;
	//GetClientRect(rcClient);
	//InvalidateRect(rcClient, TRUE);
	//_CalcImageSize();


	return bRet;
}
コード例 #2
0
ファイル: DjvuPic.cpp プロジェクト: mar80nik/testWMF
int DjvuPic::SetBuffer(CString& fullName,bool check)
{	
	int err=ERR_OK;

	Buffer->Destroy(); 
	Buffer->Create(Parent, Foreground->INFO.bmiHeader.biWidth, Foreground->INFO.bmiHeader.biHeight, 8); 
	Buffer->CreateGrayPallete();			
	CImage TT; TT.Load(FrgFile); TT.BitBlt(Buffer->GetDC(),0,0);
	return err;
}
コード例 #3
0
void CChildView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	// 로드된 이미지
	CImage img;
	LPCTSTR imgPath = imgpath_;
	img.Load(imgPath);

	// 화면 DC에 출력
	if(img != NULL) {
		img.BitBlt(dc.m_hDC, 0, 0);
	}
	else {
		return;
	}
}
コード例 #4
0
ファイル: CardControl.cpp プロジェクト: 275958081/netfox
//重画函数
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;
}
コード例 #5
0
ファイル: ChildView.cpp プロジェクト: hiccupzhu/misc_starting
// Initialization
void CChildView::InitImage()
{
    CImage image;
    image.LoadFromResource(AfxGetInstanceHandle(), IDB_BITMAP_SAMPLE);

    if ( image.IsNull() )
        return;

    // create 32 bpp image
    m_Image.Create(
        image.GetWidth(),
        image.GetHeight(),
        32);

    int nPitch = m_Image.GetPitch();
    int nWidth = m_Image.GetWidth();
    int nHeight = m_Image.GetHeight();

    ASSERT( m_Image.IsDIBSection() );
    ASSERT( abs(nPitch) == nWidth * 4 );

    // copy from image to m_Image
    image.BitBlt(
        m_Image.GetDC(),
        0, 
        0);

    m_Image.ReleaseDC();


    // get pointer to start of the image in memory
    if ( nPitch > 0 )
        m_pImageBits = (BYTE*) m_Image.GetBits();
    else
        m_pImageBits = (BYTE*) m_Image.GetBits() - (nHeight - 1) * nWidth * 4;

    // keep initial image state in m_pInitialImage array
    m_pInitialImage = new BYTE[nWidth * nHeight * 4];
    memcpy(m_pInitialImage, m_pImageBits, nWidth * nHeight * 4);

}
コード例 #6
0
void CDlgCapCam::UpdateImage(void)
{
	int i;
	CPen cur_pen, *old_pen=NULL;
	CBrush cur_brush,*old_brush = NULL;
	CPoint point;
	CSize size;
	CRect rect_image;
	CImage * pimage;
	CString str_dis;
	CRect client_rect1;
	CSize paint_size1;
	__time32_t l_time;

	if (!m_img_show.IsNull())
	{
		pimage = &m_img_show;
		_time32(&l_time);

		CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW);
		CDC* pDC1 = pDis1->GetDC();
		CDC MemDC1;
		CBitmap MemBitmap1;
		CPen pen_target;

		rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1);
		pDis1->GetClientRect(&client_rect1);
		MemDC1.CreateCompatibleDC(pDC1);
		MemBitmap1.CreateCompatibleBitmap(pDC1,rect_image.Width(),rect_image.Height());
		MemDC1.SelectObject(&MemBitmap1);

		MemDC1.SetStretchBltMode(COLORONCOLOR);
		pDC1->SetStretchBltMode(COLORONCOLOR);

		pimage->BitBlt(MemDC1.GetSafeHdc(),rect_image, CPoint(0,0),SRCCOPY);

		//draw other osd targets
		pen_target.CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
		MemDC1.SelectStockObject(NULL_BRUSH);
		MemDC1.SelectObject(&pen_target);
		for (i=0; i<m_proc_result_buf.target_set.num; i++)
		{

			MemDC1.Rectangle(m_proc_result_buf.target_set.targets[i].rect.left,
				m_proc_result_buf.target_set.targets[i].rect.bottom,
				m_proc_result_buf.target_set.targets[i].rect.right,
				m_proc_result_buf.target_set.targets[i].rect.top);

		}

		//修改事件抓拍为每10秒钟1次
#define SNATCH_TIME_INTER 10
#define SNATCH_TIME_LATE	120

		time_t cur_time;
		struct tm * now_time;

		time(&cur_time);
		now_time = localtime(&cur_time);

		if (m_proc_result_buf.target_set.num > 0)
		{
			if (cur_time - m_trigger_snatch_time >= SNATCH_TIME_INTER)				
			{
				//超过10s间隔
				ScreenShot(1, SNATCH_TIME_INTER);

				m_trigger_snatch_time = cur_time;
			}
		}

		//延续120秒
		else if(m_trigger_snatch_time > 0 && cur_time - m_trigger_snatch_time <=SNATCH_TIME_LATE)
		{
			ScreenShot(SNATCH_TIME_LATE/SNATCH_TIME_INTER, SNATCH_TIME_INTER);
			m_trigger_snatch_time = 0;
		}


		if (!m_proc_result_buf.flg_used)
		{
			if (m_proc_result_buf.target_set.num)
			{
				((CSTEvaluationDlg*)pWndParent)->AddTarget(&m_proc_result_buf.target_set);
			}
			//do event
			for (i=0; i<m_proc_result_buf.event_set.num; i++)
			{
				//摄像头采集的,帧数置零
				((CSTEvaluationDlg*)pWndParent)->AddEvent(0,l_time,m_proc_result_buf.event_set.events[i].type);
				//同时触发抓拍
				//ScreenShot(12, 10);
			}

			//防止由于刷新,事件被触发两次
			m_proc_result_buf.flg_used = TRUE;
		}



		//---------------------抓拍的操作-------------------
		//if (WaitForSingleObject(m_proc_flgscreenshot, 0) == WAIT_OBJECT_0)
		if (m_snatch_count>0 && l_time - m_snatch_pretime>=m_snatch_intertime)
		{
			CImage img;
			CString str_name;
			time_t cur_time;
			struct tm * now_time;
			str_name = ((CSTEvaluationDlg*)pWndParent)->file_path;
			str_name += +_T("\\screenshot\\");
			time(&cur_time);
			now_time = localtime(&cur_time);
			str_name.AppendFormat(_T("_%012d_alarm.jpg"), cur_time);
			img.Attach(MemBitmap1);
			img.Save(str_name);
			img.Detach();

			m_snatch_count--;
			m_snatch_pretime = l_time;
		}

		pDC1->StretchBlt(0,0,STE_IMAGE_WIDTH*2-1,STE_IMAGE_HEIGH*2-1,&MemDC1,0,0,rect_image.Width()-1, rect_image.Height()-1, SRCCOPY);

		pDis1->ReleaseDC(pDC1);

	}
	else
	{
		pimage = &m_img_def;

		CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW);
		CDC* pDC1 = pDis1->GetDC();
		rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1);	
		pDis1->GetClientRect(&client_rect1);
		pimage->StretchBlt(pDC1->GetSafeHdc(),client_rect1, rect_image, SRCCOPY);

		pDis1->ReleaseDC(pDC1);
	}

#ifdef _DEBUG
	if (!m_img1.IsNull())
	{
		pimage = &m_img1;

		//CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW);
		CDC* pDC1 = GetDC();
		rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1);
		GetClientRect(&client_rect1);
		pimage->StretchBlt(pDC1->GetSafeHdc(),CRect(380,20, 380+175, 20+143), rect_image);
		//pimage->BitBlt(pDC1->GetSafeHdc(), 500,0,352,288, 0,0,SRCCOPY);
		ReleaseDC(pDC1);
	}
	if (!m_img2.IsNull())
	{
		pimage = &m_img2;

		//CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW);
		CDC* pDC1 = GetDC();
		rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1);
		GetClientRect(&client_rect1);
		pimage->StretchBlt(pDC1->GetSafeHdc(),CRect(380,170, 380+175, 170+143), rect_image);
		//pimage->BitBlt(pDC1->GetSafeHdc(), 500,0,352,288, 0,0,SRCCOPY);
		ReleaseDC(pDC1);
	}
	if (!m_img3.IsNull())
	{
		pimage = &m_img3;

		//CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW);
		CDC* pDC1 = GetDC();
		rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1);
		GetClientRect(&client_rect1);
		pimage->StretchBlt(pDC1->GetSafeHdc(),CRect(560,20, 560+175, 20+143), rect_image);
		//pimage->BitBlt(pDC1->GetSafeHdc(), 500,0,352,288, 0,0,SRCCOPY);
		ReleaseDC(pDC1);
	}
	if (!m_img4.IsNull())
	{
		pimage = &m_img4;

		//CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW);
		CDC* pDC1 = GetDC();
		rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1);
		GetClientRect(&client_rect1);
		pimage->StretchBlt(pDC1->GetSafeHdc(),CRect(560,170, 560+175, 170+143), rect_image);
		//pimage->BitBlt(pDC1->GetSafeHdc(), 500,0,352,288, 0,0,SRCCOPY);
		ReleaseDC(pDC1);
	}	

#endif
	

	//因为帧数等信息和图像相关,所以也放在此处更新
	__time32_t n_time = 0;
	if (m_flg_process)
	{
		_time32(&n_time);
	}


	//str_dis.Format(_T("Frame:%06d;   Time(s):%06d"), m_proc_result_buf.frame_index, n_time-m_start_time);
	str_dis.Format(_T("Frame:%02d;   Time: %02dm:%02ds"), m_proc_result_buf.frame_index,
		(n_time-m_start_time)/60, 
		(n_time-m_start_time)%60);
	GetDlgItem(IDC_STATIC_STATUS)->SetWindowText(str_dis);
}
コード例 #7
0
ファイル: RDVView.cpp プロジェクト: Chessa/rdp
// Received data event from the desktop server, now read the data
LRESULT CRDVView::OnReceiveData(WPARAM wParam,LPARAM lParam)
{
	// Receive the data
	CPacket * pPacket = NULL;

	// Receive the packet of data
	if (lParam)
	{
		// Image has been received in a thread and sent
		pPacket = (CPacket *)lParam;
	}
	else
	{
		// Read the packet from the main connection
		pPacket = new CPacket;
		CPacket & Packet = *pPacket;
		m_Socket >> Packet;
	}

	// Make it easy to work with either packet
	CPacket & Packet = *pPacket;

	// Process the data
	if (Packet.m_ucPacketType == 7)
	{
		// Create the temporary DIB
		CDIBFrame DIBPacket;
		DIBPacket.Init(Packet.m_Rect.Width(),Packet.m_Rect.Height(),m_nBitCount);

		// Point to the internal buffer of the DIB
		char * pBuffer = (LPSTR)DIBPacket;
		DWORD dwBytes = Packet.m_dwBytes;

		// Test for compression
		if (Packet.m_bUseCompression)
		{
			// Test for multi-threaded compression
			if (Packet.m_nCompThreads)
			{
				// Set the type of encoder
				m_pMTC->SetEncoder(Packet.m_bAC);

				// Multithreaded arithmetic decoding
				m_pMTC->SetBuffer(Packet.m_pBuffer,Packet.m_bAC ? Packet.m_dwBytes : Packet.m_dwSrcBytes,FALSE);
				m_pMTC->Decode();

				// Get the output buffer
				m_pMTC->GetBuffer(&pBuffer,&dwBytes,FALSE,FALSE);
			}
			else
			{
				if (Packet.m_bAC)
				{
					// Single-threaded arithmetic encoding
					m_AC.DecodeBuffer(Packet.m_pBuffer,Packet.m_dwBytes,&pBuffer,&dwBytes,FALSE);
				}
				else
				{
					// Single-threaded zlib uncompressing
					dwBytes = Packet.m_dwSrcBytes;
					m_ZLib.DecodeBuffer(Packet.m_pBuffer,Packet.m_dwBytes,pBuffer,dwBytes,FALSE);
				}
			}
		}
		else
		{
			// Copy the uncompressed DIB to the output
			memcpy(pBuffer,Packet.m_pBuffer,dwBytes);
		}

		// Get the image type
		BOOL bDIB = Packet.m_bDIB;

		// Get the reset attribute
		BOOL bXOR = Packet.m_bXOR;

		// Get the delta DIB
		CDIBFrame & XOR = m_XOR;

		// Get the viewed DIB
		CDIBFrame & DIB = m_DIB;

		// Get the rectangular coordinates
		CRect Rect = Packet.m_Rect;

		// Check for a PNG
		if (!bDIB)
		{
			// JPEG support
			COleStreamFile ImageStream;

			// Prepare the Image for memory stream serialization
			if (ImageStream.CreateMemoryStream())
			{
				// Write the packet to the stream
				ImageStream.Write(pBuffer,dwBytes);
				IStream * pImageStream = ImageStream.GetStream();

				// Load the image from the stream
				CImage ImageDIB;
				if (pImageStream && SUCCEEDED(ImageDIB.Load(pImageStream)))
				{
					// Transfer the PNG to a DIB
					ImageDIB.BitBlt(DIBPacket,0,0,SRCCOPY);

					// Release the stream
					pImageStream->Release();
				}
			}
		}

		if (bXOR)
		{
			// XOR the current desktop with the last
			BitBlt(DIB,Rect.left,Rect.top,Rect.Width(),Rect.Height(),DIBPacket,0,0,SRCINVERT);
		}
		else
		{
			// Copy over the current desktop
			BitBlt(DIB,Rect.left,Rect.top,Rect.Width(),Rect.Height(),DIBPacket,0,0,SRCCOPY);
		}

		// Update the last DIB
		BitBlt(XOR,0,0,m_cxWidth,m_cyHeight,DIB,0,0,SRCCOPY);

		// Update the screen
		InvalidateRect(NULL,FALSE);
		UpdateWindow();
	}
	else if (Packet.m_ucPacketType == 3) // Cursor
	{
		// Get the cursor data
		DWORD dwXHotSpot = Packet.m_dwXHotSpot;
		DWORD dwYHotSpot = Packet.m_dwYHotSpot;
		int nWidth = Packet.m_bmWidth;
		int nHeight = Packet.m_bmHeight;
		WORD bmMaskPlanes = Packet.m_bmMaskPlanes;
		WORD bmMaskBitsPixel = Packet.m_bmMaskBitsPixel;
		WORD bmColorPlanes = Packet.m_bmColorPlanes;
		WORD bmColorBitsPixel = Packet.m_bmColorBitsPixel;
		BYTE * pMaskBits = NULL;
		BYTE * pColorBits = NULL;
		if (Packet.m_MaskBits.size())
			pMaskBits = &(Packet.m_MaskBits[0]);
		if (Packet.m_ColorBits.size())
			pColorBits = &(Packet.m_ColorBits[0]);

		// Create a cursor
		m_Cursor.CreateCursor(dwXHotSpot,dwYHotSpot,nWidth,nHeight,bmMaskPlanes,bmMaskBitsPixel,bmColorPlanes,bmColorBitsPixel,pMaskBits,pColorBits);

		// Set the cursor
		SetClassLong(m_hWnd,-12,(LONG)(HCURSOR)m_Cursor);
		SetCursor(m_Cursor);
	}
	else if (Packet.m_ucPacketType == 2) // Display characteristics
	{
		// Free the previous multithread AC encoder
		if (m_pMTC)
		{
			delete m_pMTC;
			m_pMTC = NULL;
		}

		// Create the multithreaded AC driver
		m_pMTC = new CDriveMultiThreadedCompression(m_nCompThreads);

		// Display characteristics
		m_cxWidth = Packet.m_cxScreen;
		m_cyHeight = Packet.m_cyScreen;
		m_nBitCount = Packet.m_nBitCount;
		m_nGridThreads = Packet.m_nGridThreads;
		m_iGridThread = 0;

		// Set the new scroll sizes
		m_ViewSize.cx = m_cxWidth;
		m_ViewSize.cy = m_cyHeight;

		// Handle the initial condition
		if (m_bViewZoom)
		{
			// Provide a full view of the server with scroll bars
			SetScrollSizes(MM_TEXT,m_ViewSize);
			GetParentFrame()->RecalcLayout();
			ResizeParentToFit();
		}
		else
		{
			// Shrink to fit the server in the client window
			SetScaleToFitSize(m_ViewSize);
			GetParentFrame()->RecalcLayout();
		}

		// Setup the GDI
		SetupGDI();

		// Send the verification
		CPacket Packet2(m_nCompThreads,0);

		// Send the packet
		m_Socket << Packet2;
	}
	else if (Packet.m_ucPacketType == 10)
	{
		// Get the number of compression threads
		m_nCompThreads = Packet.m_nCompThreads;

		if (Packet.m_nSessionId == 0)
		{
			// Get the password for verification
			CString csPassword = GetDocument()->m_csPassword;

			// If the session is set then this verification to the server that the handshaking is over for the thread connection
			CPacket Packet2(csPassword,m_nSessionId);

			// Send the packet
			m_Socket << Packet2;
		}
		else
		{
			// Set the session id for the main connection and then set the timer for making the other connections
			if (!m_nSessionId)
			{
				// Get the session id
				m_nSessionId = Packet.m_nSessionId;

				// Make server connections for each update rectangle thread
				SetTimer(2,0,NULL);
			}
			else
			{
				// Close the document
				GetDocument()->OnCloseDocument();
			}
		}
	}

	// Clean up the packet if it needed to be created
	if (!lParam)
		delete pPacket;

	return 1;
}
コード例 #8
0
//绘画背景
BOOL CGameFrameMedalView::OnEraseBkgnd(CDC * pDC)
{
	//获取位置
	CRect rcClient;
	GetClientRect(&rcClient);

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

	//创建 DC
	CImageDC BufferDC(ImageBuffer);
	CDC * pBufferDC=CDC::FromHandle(BufferDC);

	//设置缓冲
	pBufferDC->SetBkMode(TRANSPARENT);
	pBufferDC->SetTextAlign(TA_LEFT|TA_TOP);
	pBufferDC->SetTextColor(RGB(250,250,250));
	pBufferDC->SelectObject(CSkinResourceManager::GetInstance()->GetDefaultFont());

	//加载资源
	CImage ImageUserMedalL;
	CImage ImageUserMedalM;
	CImage ImageUserMedalR;
	ImageUserMedalL.LoadFromResource(GetModuleHandle(GAME_FRAME_DLL_NAME),IDB_USER_MEDAL_L);
	ImageUserMedalM.LoadFromResource(GetModuleHandle(GAME_FRAME_DLL_NAME),IDB_USER_MEDAL_M);
	ImageUserMedalR.LoadFromResource(GetModuleHandle(GAME_FRAME_DLL_NAME),IDB_USER_MEDAL_R);

	//变量定义
	INT nXStartPos=ImageUserMedalL.GetWidth();
	INT nXConcludePos=rcClient.Width()-ImageUserMedalR.GetWidth();

	//绘画框架
	ImageUserMedalL.BitBlt(BufferDC,0,0);
	ImageUserMedalR.BitBlt(BufferDC,rcClient.Width()-ImageUserMedalR.GetWidth(),0);

	//绘画中间
	for (INT nXPos=nXStartPos;nXPos<nXConcludePos;nXPos+=ImageUserMedalM.GetWidth())
	{
		INT nCXDraw=__min(ImageUserMedalM.GetWidth(),nXConcludePos-nXPos);
		ImageUserMedalM.BitBlt(BufferDC,nXPos,0,nCXDraw,ImageUserMedalM.GetHeight(),0,0);
	}

	//加载资源
	CPngImageSB ImageCount;
	CPngImageSB ImageStringL;
	CPngImageSB ImageStringR;
	ImageCount.LoadImage(GetModuleHandle(GAME_FRAME_DLL_NAME),TEXT("MEDAL_COUNT"));
	ImageStringL.LoadImage(GetModuleHandle(GAME_FRAME_DLL_NAME),TEXT("MEDAL_STRING_L"));
	ImageStringR.LoadImage(GetModuleHandle(GAME_FRAME_DLL_NAME),TEXT("MEDAL_STRING_R"));

	//获取大小
	CSize SizeCount;
	CSize SizeStringL;
	CSize SizeStringR;
	SizeCount.SetSize(ImageCount.GetWidth()/10L,ImageCount.GetHeight());
	SizeStringL.SetSize(ImageStringL.GetWidth(),ImageStringL.GetHeight());
	SizeStringR.SetSize(ImageStringR.GetWidth(),ImageStringR.GetHeight());

	//构造奖牌
	TCHAR szUserMedal[16]=TEXT("");
	_sntprintf(szUserMedal,CountArray(szUserMedal),TEXT("%ld"),m_dwUserMedal);

	//变量定义
	INT nNumCount=lstrlen(szUserMedal);
	INT nNumStart=(rcClient.Width()-nNumCount*SizeCount.cx)/2+10;

	//绘画字符
	ImageStringL.DrawImage(pBufferDC,nNumStart-SizeStringL.cx-3,4);
	ImageStringR.DrawImage(pBufferDC,nNumStart+nNumCount*SizeCount.cx+3,4);

	//绘画奖牌
	for (INT i=0;i<nNumCount;i++)
	{
		INT nXImage=(szUserMedal[i]-TEXT('0'))*SizeCount.cx;
		ImageCount.DrawImage(pBufferDC,nNumStart+i*SizeCount.cx,7,SizeCount.cx,SizeCount.cy,nXImage,0);
	}

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

	return TRUE;
}
コード例 #9
0
ファイル: SkinImage.cpp プロジェクト: Michael-Z/qipai-game
//混合绘画
bool CSkinImage::BlendDrawImage(CDC * pDestDC, INT xDest, INT yDest, INT cxDest, INT cyDest, INT xSrc, INT ySrc, COLORREF crTransColor, BYTE cbAlphaDepth)
{
	//无效区域
	CRect rcDirty;
	pDestDC->GetClipBox(&rcDirty);

	//绘画判断
	if (IsNull()==true) return false;

	//位置调整
	tagImageRender ImageRender;
	GetDrawImageArea(xDest,yDest,cxDest,cyDest,xSrc,ySrc,rcDirty,ImageRender);

	//创建位图
	CImage ImageResult;
	CImage ImageSource;
	ImageResult.Create(ImageRender.cxRender,ImageRender.cyRender,32);
	ImageSource.Create(ImageRender.cxRender,ImageRender.cyRender,32);

	//绘画位图
	CDC * pDCImage=CDC::FromHandle(GetDC());
	CDC * pDCResult=CDC::FromHandle(ImageResult.GetDC());
	CDC * pDCSource=CDC::FromHandle(ImageSource.GetDC());
	pDCSource->BitBlt(0,0,ImageRender.cxRender,ImageRender.cyRender,pDCImage,ImageRender.nXImage,ImageRender.nYImage,SRCCOPY);
	pDCResult->BitBlt(0,0,ImageRender.cxRender,ImageRender.cyRender,pDestDC,ImageRender.nXScreen,ImageRender.nYScreen,SRCCOPY);

	//获取属性
	float fAlpha=(float)(cbAlphaDepth/255.0);
	INT nPitchResult=ImageResult.GetPitch();
	INT nPitchSource=ImageSource.GetPitch();

	//获取数据
	LPBYTE cbBitResult=(LPBYTE)ImageResult.GetBits();
	LPBYTE cbBitSource=(LPBYTE)ImageSource.GetBits();

	//创建区域
	for (INT nYPos=0;nYPos<ImageRender.cyRender;nYPos++)
	{
		for (INT nXPos=0;nXPos<ImageRender.cxRender;nXPos++)
		{
			//获取颜色
			COLORREF * pcrResult=(COLORREF *)(cbBitResult+nYPos*nPitchResult+nXPos*4);
			COLORREF * pcrSource=(COLORREF *)(cbBitSource+nYPos*nPitchSource+nXPos*4);

			//混合处理
			if (*pcrSource!=crTransColor)
			{
				//结果颜色
				BYTE cbResultR=GetRValue(*pcrResult);
				BYTE cbResultG=GetGValue(*pcrResult);
				BYTE cbResultB=GetBValue(*pcrResult);

				//原图颜色
				BYTE cbSourceR=GetRValue(*pcrSource);
				BYTE cbSourceG=GetGValue(*pcrSource);
				BYTE cbSourceB=GetBValue(*pcrSource);

				//颜色混合
				cbResultR=(BYTE)(cbSourceR*fAlpha+cbResultR*(1.0-fAlpha));
				cbResultG=(BYTE)(cbSourceG*fAlpha+cbResultG*(1.0-fAlpha));
				cbResultB=(BYTE)(cbSourceB*fAlpha+cbResultB*(1.0-fAlpha));

				//颜色混合
				*pcrResult=RGB(cbResultR,cbResultG,cbResultB);
			}
		}
	}

	//绘画界面
	ImageResult.BitBlt(pDestDC->m_hDC,ImageRender.nXScreen,ImageRender.nYScreen);

	//释放对象
	ReleaseDC();
	ImageSource.ReleaseDC();
	ImageResult.ReleaseDC();

	return true;
}
コード例 #10
0
//显示图片到DC,ratio为显示百分比
void display(HDC hdc,CImage &image,double ratio)
{
	CImage dstImg;
	Scaling(image,dstImg,ratio);
	dstImg.BitBlt(hdc,0,0,dstImg.GetWidth(),dstImg.GetHeight(),0,0,SRCCOPY);
}
コード例 #11
0
//绘画背景
BOOL CPasswordKeyboard::OnEraseBkgnd(CDC * pDC)
{
	//获取位置
	CRect rcClient;
	GetClientRect(&rcClient);

	//创建缓冲
	CDC BufferDC;
	CBitmap ImageBuffer;
	BufferDC.CreateCompatibleDC(pDC);
	ImageBuffer.CreateCompatibleBitmap(pDC,rcClient.Width(),rcClient.Height());

	//设置环境
	BufferDC.SetBkMode(TRANSPARENT);
	BufferDC.SelectObject(&ImageBuffer);
	BufferDC.SelectObject(CSkinResourceManager::GetInstance()->GetDefaultFont());

	//变量定义
	HINSTANCE hResInstance=GetModuleHandle(SHARE_CONTROL_DLL_NAME);
	CSkinRenderManager * pSkinRenderManager=CSkinRenderManager::GetInstance();

	//加载资源
	CImage ImageItem1;
	CImage ImageItem2;
	CImage ImageItem3;
	CImage ImageButton;
	CImage ImageBackGround;
	ImageItem1.LoadFromResource(hResInstance,IDB_KEYBOARD_ITEM1);
	ImageItem2.LoadFromResource(hResInstance,IDB_KEYBOARD_ITEM2);
	ImageItem3.LoadFromResource(hResInstance,IDB_KEYBOARD_ITEM3);
	ImageButton.LoadFromResource(hResInstance,IDB_BT_KEYBOARD_CLOSE);
	ImageBackGround.LoadFromResource(hResInstance,IDB_PASSWORD_KEYBORAD_BK);

	//渲染资源
	pSkinRenderManager->RenderImage(ImageItem1);
	pSkinRenderManager->RenderImage(ImageItem2);
	pSkinRenderManager->RenderImage(ImageItem3);
	pSkinRenderManager->RenderImage(ImageButton);
	pSkinRenderManager->RenderImage(ImageBackGround);

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

	//字符按钮
	for (INT nLine=0;nLine<CountArray(m_nItemCount);nLine++)
	{
		//绘画子项
		for (INT nRow=0;nRow<m_nItemCount[nLine];nRow++)
		{
			//计算位置
			INT nXImageIndex=0;
			INT nCharItemIndex=(nRow+m_nRandLine[nLine])%m_nItemCount[nLine];
			if ((m_wHoverLine==nLine)&&(m_wHoverRow==nRow)) nXImageIndex=(m_bMouseDown==false)?1:2;

			//绘画子项
			INT nXDrawPos=ITEM_POS_X+(m_SizeImageItem1.cx+ITEM_POS_S)*nRow;
			INT nYDrawPos=ITEM_POS_Y+(m_SizeImageItem1.cy+ITEM_POS_S)*nLine;
			ImageItem1.BitBlt(BufferDC,nXDrawPos,nYDrawPos,m_SizeImageItem1.cx,m_SizeImageItem1.cy,nXImageIndex*m_SizeImageItem1.cx,0);

			//构造颜色
			INT nColorIndex=0;
			COLORREF crTextColor[2]={RGB(0,0,0),RGB(125,125,125)};

			//颜色计算
			if (m_bShiftStatus==true) nColorIndex=(nColorIndex+1)%CountArray(crTextColor);
			if ((m_bCapsLockStatus==true)&&(nLine>=2)) nColorIndex=(nColorIndex+1)%CountArray(crTextColor);

			//绘画字符
			BufferDC.SetTextColor(crTextColor[nColorIndex]);
			BufferDC.TextOut(nXDrawPos+5,nYDrawPos+9,&m_szKeyboradChar[nLine][0][nCharItemIndex],1);

			//绘画字符
			BufferDC.SetTextColor(crTextColor[(nColorIndex+1)%CountArray(crTextColor)]);
			BufferDC.TextOut(nXDrawPos+15,nYDrawPos+3,&m_szKeyboradChar[nLine][1][nCharItemIndex],1);
		}
	}

	//退格按钮
	{
		//资源位置
		INT nXImageIndex=0;
		if ((m_wHoverLine==LINE_FUNCTION)&&(m_wHoverRow==ROW_BACK)) nXImageIndex=(m_bMouseDown==false)?1:2;

		//绘画背景
		INT nYDrawPos=ITEM_POS_Y;
		INT nXDrawPos=ITEM_POS_X+(m_SizeImageItem1.cx+ITEM_POS_S)*m_nItemCount[0];
		ImageItem3.BitBlt(BufferDC,nXDrawPos,nYDrawPos,m_SizeImageItem3.cx,m_SizeImageItem3.cy,nXImageIndex*m_SizeImageItem3.cx,0);

		//绘画字符
		BufferDC.SetTextColor(RGB(0,0,0));
		BufferDC.TextOut(nXDrawPos+20,ITEM_POS_Y+7,TEXT("←"),2);
	}

	//切换按钮
	{
		//资源位置
		INT nXImageIndex=(m_bShiftStatus==true)?1:0;
		if ((m_wHoverLine==LINE_FUNCTION)&&(m_wHoverRow==ROW_SHIFT)) nXImageIndex=(m_bMouseDown==false)?1:2;

		//绘画背景
		INT nYDrawPos=ITEM_POS_Y+ITEM_POS_S+m_SizeImageItem1.cx;
		INT nXDrawPos=ITEM_POS_X+(m_SizeImageItem1.cx+ITEM_POS_S)*m_nItemCount[1];
		ImageItem2.BitBlt(BufferDC,nXDrawPos,nYDrawPos,m_SizeImageItem2.cx,m_SizeImageItem2.cy,nXImageIndex*m_SizeImageItem2.cx,0);

		//切换按钮
		BufferDC.SetTextColor(RGB(0,0,0));
		BufferDC.TextOut(nXDrawPos+5,ITEM_POS_Y+ITEM_POS_S+m_SizeImageItem1.cx+6,TEXT("Shift"),5);
	}

	//大写按钮
	{
		//资源位置
		INT nXImageIndex=(m_bCapsLockStatus==true)?1:0;
		if ((m_wHoverLine==LINE_FUNCTION)&&(m_wHoverRow==ROW_CAPITAL)) nXImageIndex=(m_bMouseDown==false)?1:2;

		//绘画背景
		INT nYDrawPos=ITEM_POS_Y+ITEM_POS_S+m_SizeImageItem1.cx;
		INT nXDrawPos=ITEM_POS_X+(m_SizeImageItem1.cx+ITEM_POS_S)*m_nItemCount[1]+m_SizeImageItem2.cx+ITEM_POS_S;
		ImageItem2.BitBlt(BufferDC,nXDrawPos,nYDrawPos,m_SizeImageItem2.cx,m_SizeImageItem2.cy,nXImageIndex*m_SizeImageItem2.cx,0);

		//大写按钮
		BufferDC.SetTextColor(RGB(0,0,0));
		BufferDC.TextOut(nXDrawPos+8,ITEM_POS_Y+ITEM_POS_S+m_SizeImageItem1.cx+6,TEXT("Caps"),4);
	}

	//关闭按钮
	{
		//资源位置
		INT nXImageIndex=0;
		if ((m_wHoverLine==LINE_FUNCTION)&&(m_wHoverRow==ROW_CLOSE_KEY)) nXImageIndex=(m_bMouseDown==false)?1:2;

		//绘画背景
		INT nXDrawPos=rcClient.Width()-m_SizeImageButton.cx-POS_BUTTON_X;
		ImageButton.BitBlt(BufferDC,nXDrawPos,POS_BUTTON_Y,m_SizeImageButton.cx,m_SizeImageButton.cy,nXImageIndex*m_SizeImageButton.cx,0);
	}

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

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

	return TRUE;
}