📄 pictureview.cpp
字号:
// PictureView.cpp : implementation file
//
#include "stdafx.h"
#include "wavelet.h"
#include "PictureView.h"
#include "WaveletDoc.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// PictureView
IMPLEMENT_DYNCREATE(PictureView, CScrollView)
PictureView::PictureView()
{
}
PictureView::~PictureView()
{
}
BEGIN_MESSAGE_MAP(PictureView, CScrollView)
//{{AFX_MSG_MAP(PictureView)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// PictureView drawing
void PictureView::OnDraw(CDC* pDC)
{
CWaveletDoc* pDoc = GetDocument();
unsigned char* pBitmap = pDoc -> m_pBitmap;
LPBITMAPINFO lpBitmapInfo = (LPBITMAPINFO)(pBitmap + 14);
unsigned char* pBitmapData = pBitmap + ((LPBITMAPFILEHEADER)pBitmap)->bfOffBits;
unsigned long biHeight = ((LPBITMAPINFOHEADER)lpBitmapInfo)->biHeight;
unsigned long biWidth = ((LPBITMAPINFOHEADER)lpBitmapInfo)->biWidth;
CRect rect;
GetClientRect(&rect);
long originx =0;
long originy =0;
if((unsigned long)(rect.Width()) > biWidth)
originx = (rect.Width() - biWidth)>>1;
if((unsigned long)(rect.Height()) > biHeight)
originy = (rect.Height() - biHeight)>>1;
SetDIBitsToDevice(pDC->m_hDC, originx, originy, biWidth, biHeight, 0, 0, 0, biHeight, pBitmapData,
lpBitmapInfo, DIB_RGB_COLORS);
}
/////////////////////////////////////////////////////////////////////////////
// PictureView diagnostics
#ifdef _DEBUG
void PictureView::AssertValid() const
{
CScrollView::AssertValid();
}
void PictureView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CWaveletDoc* PictureView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWaveletDoc)));
return (CWaveletDoc*)m_pDocument;
}
#endif //_DEBUG
void PictureView::OnInitialUpdate()
{ CScrollView::OnInitialUpdate();
CWaveletDoc* pDoc = GetDocument();
unsigned char* pBitmap = pDoc -> m_pBitmap;
LPBITMAPINFO lpBitmapInfo = (LPBITMAPINFO)(pBitmap + 14);
int biHeight = ((LPBITMAPINFOHEADER)lpBitmapInfo)->biHeight;
int biWidth = ((LPBITMAPINFOHEADER)lpBitmapInfo)->biWidth;
CSize sizeTotal(biWidth, biHeight);
SetScrollSizes(MM_TEXT, sizeTotal);
CMainFrame* pAppFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
ASSERT_KINDOF(CMainFrame, pAppFrame);
CRect rc;
pAppFrame->GetClientRect(&rc);
if (rc.Width() >= sizeTotal.cx && rc.Height() >= sizeTotal.cy &&
(sizeTotal.cx>0 || sizeTotal.cy>0))
ResizeParentToFit(FALSE);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -