class CROIDialog : public CDialogEx
{
DECLARE_DYNAMIC(CROIDialog)
public:
CROIDialog(CWnd* pParent = NULL); // 标准构造函数
virtual ~CROIDialog();
CStatic m_StaticDisplay;
CRect m_rDrawingSurface;
//}}AFX_DATA
float m_xScale;
float m_yScale;
int m_xLeft;
int m_yTop;
int m_nImageLength;
char* yuv420ScreenImage;
char* rgbScreenImage;
Coordinates points;
enum { IDD = IDD_ROI_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
};
void CROIDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
LARGE_INTEGER litmp;
LONGLONG QPart1,QPart2;
double dfMinus, dfFreq, dfTim;
QueryPerformanceFrequency(&litmp);
dfFreq = (double)litmp.QuadPart;// 获得计数器的时钟频率
QueryPerformanceCounter(&litmp);
QPart1 = litmp.QuadPart;// 获得初始值
CString str;
CDC *pdc=GetDC();
CWnd *pWnd = GetDlgItem(IDC_ROI_STATIC);
pWnd->GetWindowRect(m_rDrawingSurface);
ScreenToClient(m_rDrawingSurface);
CDC* pMem = new CDC;
CBitmap* pBmp = new CBitmap;
CBitmap* pOldBmp;
pBmp->CreateCompatibleBitmap(pdc,m_rDrawingSurface.Width(),m_rDrawingSurface.Height());
pMem->CreateCompatibleDC(pdc);
HDC hdcMem = pMem->GetSafeHdc();
pOldBmp = pMem->SelectObject(pBmp);
unsigned long len;
YUV2RGB((LPBYTE)yuv420ScreenImage,g_screenWidth[0],g_screenHeight[0],(LPBYTE)rgbScreenImage,len);
ShowImage(pMem,(BYTE *)rgbScreenImage);
pdc->BitBlt(m_rDrawingSurface.TopLeft().x,m_rDrawingSurface.TopLeft().y,
m_rDrawingSurface.Width(),m_rDrawingSurface.Height(), pMem, 0, 0, SRCCOPY);
pMem->SelectObject(pOldBmp);
pMem->DeleteDC();
pBmp->DeleteObject();
pOldBmp->DeleteObject();
ReleaseDC(pdc);
delete pBmp;
delete pMem;
QueryPerformanceCounter(&litmp);
QPart2 = litmp.QuadPart;//获得中止值
dfMinus = (double)(QPart2-QPart1);
dfTim = dfMinus / dfFreq;// 获得对应的时间值,单位为秒
}
void CROIDialog::ShowImage(CDC* pDC, BYTE * lpImage)
{
pDC->SetStretchBltMode(STRETCH_DELETESCANS);
int displayLowerLeftX = displayOffsetFromFrameOriginX;
int displayLowerLeftY = displayOffsetFromFrameOriginY;
int frameWidth = g_screenWidth[0];
int frameHeight = g_screenHeight[0];
StretchDIBits(pDC->m_hDC, displayLowerLeftX, displayLowerLeftY,
m_rDrawingSurface.Width(),m_rDrawingSurface.Height(),
displayLowerLeftX,
displayLowerLeftY,
frameWidth,
frameHeight,
lpImage, bitmapInfo, DIB_RGB_COLORS,SRCCOPY);
}
{
DECLARE_DYNAMIC(CROIDialog)
public:
CROIDialog(CWnd* pParent = NULL); // 标准构造函数
virtual ~CROIDialog();
CStatic m_StaticDisplay;
CRect m_rDrawingSurface;
//}}AFX_DATA
float m_xScale;
float m_yScale;
int m_xLeft;
int m_yTop;
int m_nImageLength;
char* yuv420ScreenImage;
char* rgbScreenImage;
Coordinates points;
enum { IDD = IDD_ROI_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
};
void CROIDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
LARGE_INTEGER litmp;
LONGLONG QPart1,QPart2;
double dfMinus, dfFreq, dfTim;
QueryPerformanceFrequency(&litmp);
dfFreq = (double)litmp.QuadPart;// 获得计数器的时钟频率
QueryPerformanceCounter(&litmp);
QPart1 = litmp.QuadPart;// 获得初始值
CString str;
CDC *pdc=GetDC();
CWnd *pWnd = GetDlgItem(IDC_ROI_STATIC);
pWnd->GetWindowRect(m_rDrawingSurface);
ScreenToClient(m_rDrawingSurface);
CDC* pMem = new CDC;
CBitmap* pBmp = new CBitmap;
CBitmap* pOldBmp;
pBmp->CreateCompatibleBitmap(pdc,m_rDrawingSurface.Width(),m_rDrawingSurface.Height());
pMem->CreateCompatibleDC(pdc);
HDC hdcMem = pMem->GetSafeHdc();
pOldBmp = pMem->SelectObject(pBmp);
unsigned long len;
YUV2RGB((LPBYTE)yuv420ScreenImage,g_screenWidth[0],g_screenHeight[0],(LPBYTE)rgbScreenImage,len);
ShowImage(pMem,(BYTE *)rgbScreenImage);
pdc->BitBlt(m_rDrawingSurface.TopLeft().x,m_rDrawingSurface.TopLeft().y,
m_rDrawingSurface.Width(),m_rDrawingSurface.Height(), pMem, 0, 0, SRCCOPY);
pMem->SelectObject(pOldBmp);
pMem->DeleteDC();
pBmp->DeleteObject();
pOldBmp->DeleteObject();
ReleaseDC(pdc);
delete pBmp;
delete pMem;
QueryPerformanceCounter(&litmp);
QPart2 = litmp.QuadPart;//获得中止值
dfMinus = (double)(QPart2-QPart1);
dfTim = dfMinus / dfFreq;// 获得对应的时间值,单位为秒
}
void CROIDialog::ShowImage(CDC* pDC, BYTE * lpImage)
{
pDC->SetStretchBltMode(STRETCH_DELETESCANS);
int displayLowerLeftX = displayOffsetFromFrameOriginX;
int displayLowerLeftY = displayOffsetFromFrameOriginY;
int frameWidth = g_screenWidth[0];
int frameHeight = g_screenHeight[0];
StretchDIBits(pDC->m_hDC, displayLowerLeftX, displayLowerLeftY,
m_rDrawingSurface.Width(),m_rDrawingSurface.Height(),
displayLowerLeftX,
displayLowerLeftY,
frameWidth,
frameHeight,
lpImage, bitmapInfo, DIB_RGB_COLORS,SRCCOPY);
}