15,979
社区成员
发帖
与我相关
我的任务
分享
//这一段在**Dlg.cpp文件开头
Graphics *m_pGraphics; // Create a global graphics pointer
Image *m_pImageAttitude; // Create a globalimage pointer
//这一段位于OnInitDialog()函数中
CDC *pDC=GetDC(); // Obtain device context
m_pGraphics = new Graphics(pDC->m_hDC); // Initialize graphics pointer
m_pGraphics->SetPageUnit(Unit::UnitPixel); // Use pixel unit
m_pImageAttitude = Bitmap::FromResource( // Obtain bitmap from resource
AfxGetApp()->m_hInstance,
(WCHAR*)(LPCTSTR)MAKEINTRESOURCE(IDB_BITMAP2));
//这一段位于专门用来刷新画面的函数中
Matrix m_matrix; // Create a unit matrix
m_matrix.Translate(………………); // Matrix translate transform
m_matrix.RotateAt(………………); // Matrix rotate transform
m_pGraphics->SetTransform(&m_matrix); // Apply transformation to image
m_pGraphics->DrawImage(m_pImageAttitude,0,0); // Display image starting at top left corner of current window
//修改过的用于刷新画面的代码:
Matrix m_matrix; // Create a unit matrix
m_matrix.Translate(………………); // Matrix translate transform
m_matrix.RotateAt(………………); // Matrix rotate transform
m_pGraphics->SetTransform(&m_matrix); // Apply transformation to image
// Inserted section start
CDC *pDC=GetDC(); // Obtain device context
Graphics rgnGraph(pDC->m_hDC); // Create a local graphics object
rgnGraph.SetPageUnit(Unit::UnitPixel); // Use pixel unit
GraphicsPath rgnPath; // Create an empty path
Rect fillRect(…,…,…,…); // Create a rectangle
rgnPath.AddRectangle(fillRect); // Add rectangle into path
Region m_rgnADI(&rgnPath); // Create a region from path
m_pGraphics->IntersectClip(&m_rgnADI); // Clip the image with region
// Inserted section end
m_pGraphics->DrawImage(m_pImageAttitude,0,0); // Display image starting at top left corner of current window
m_matrix.Translate(………………); // Matrix translate transform
m_pGraphics->DrawImage(m_pImageAttitude,0,0);
m_pGraphics->ResetTransform();
m_pGraphics->SetClip(&m_rgnADI,CombineModeIntersect);