📄 showtracedpicture.cpp
字号:
// ShowTracedPicture.cpp : implementation file
//
#include "stdafx.h"
#include "noname.h"
#include "ShowTracedPicture.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CShowTracedPicture dialog
CShowTracedPicture::CShowTracedPicture(CWnd* pParent /*=NULL*/)
: CDialog(CShowTracedPicture::IDD, pParent)
{
m_nWndWidth = SCRWIDTH;
m_nWndHeight= SCRHEIGHT;
m_Buffer=NULL;
}
CShowTracedPicture::~CShowTracedPicture()
{
if( m_Buffer==NULL)
{
return;
}
for(int i=0;i<m_nWndHeight;i++)
{
delete m_Buffer[i];
}
delete m_Buffer;
}
void CShowTracedPicture::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CShowTracedPicture)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CShowTracedPicture, CDialog)
//{{AFX_MSG_MAP(CShowTracedPicture)
ON_BN_CLICKED(IDC_BUTTON_ShowPic, OnBUTTONShowPic)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CShowTracedPicture message handlers
void CShowTracedPicture::LoadOriPixel(RGBQUAD** Buffer)
{
int byteBitCount=3;
m_Buffer = new RGBQUAD*[m_nWndHeight];
for(int l=0 ; l<m_nWndHeight; l++)
{
m_Buffer[l] = new RGBQUAD[m_nWndWidth];
}
int count = 0;
for(int i=0; i<m_nWndHeight; i++)
{
for(int j=0; j<m_nWndWidth; j++)
{
m_Buffer[i][j].rgbBlue =Buffer[i][j].rgbBlue;
m_Buffer[i][j].rgbGreen=Buffer[i][j].rgbGreen;
m_Buffer[i][j].rgbRed =Buffer[i][j].rgbRed;
m_Buffer[i][j].rgbReserved = 0;
}
}
}
void CShowTracedPicture::MakeBitMap()
{
CClientDC ClientDC(pDCShow->GetWindow());
if(m_pResMap!=NULL) delete m_pResMap;
m_pResMap=new CBitmap();
m_pResMap->CreateCompatibleBitmap(&ClientDC,m_nWndWidth,m_nWndHeight);
CDC dc;
dc.CreateCompatibleDC(&ClientDC);
dc.SelectObject(m_pResMap);
for(int i=0; i<m_nWndHeight; i++)
for(int j=0; j<m_nWndWidth; j++)
//dc.SetPixel(j,i,m_Buffer[i*m_nWndWidth+j]);
dc.SetPixel(j,i,RGB(m_Buffer[i][j].rgbRed,m_Buffer[i][j].rgbGreen,m_Buffer[i][j].rgbBlue));
dc.DeleteDC();
MyDraw();
}
void CShowTracedPicture::MyDraw()
{
CRect rc;
pDCShow->GetWindow()->GetClientRect(&rc);
pDCShow->Rectangle(&rc);
CDC dc;
CBitmap *pOldBitmap;
dc.CreateCompatibleDC(pDCShow);
pOldBitmap=dc.SelectObject(m_pResMap);
pDCShow->StretchBlt(0,0,m_nWndWidth,m_nWndHeight,&dc,0,0,m_nWndWidth,m_nWndHeight,SRCCOPY);
dc.SelectObject(pOldBitmap);
dc.DeleteDC();
}
BOOL CShowTracedPicture::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CWnd *pWnd0= GetDlgItem(IDC_ShowTracedPicture);
pDCShow = pWnd0->GetDC();
// m_pMainDib = new CDib();
m_tOriPixelArray = NULL;
m_pResMap = NULL;
MakeBitMap();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CShowTracedPicture::OnBUTTONShowPic()
{
MakeBitMap();
}
void CShowTracedPicture::OnPaint()
{
CPaintDC dc(this); // device context for painting
MakeBitMap();
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -