ImageView.cpp
上传用户:aqingfeng
上传日期:2014-03-25
资源大小:1839k
文件大小:2k
- // ImageView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "小波变换.h"
- #include "ImageView.h"
- #include "小波变换Doc.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CImageView
- IMPLEMENT_DYNCREATE(CImageView, CView)
- CImageView::CImageView()
- {
- }
- CImageView::~CImageView()
- {
- }
- BEGIN_MESSAGE_MAP(CImageView, CView)
- //{{AFX_MSG_MAP(CImageView)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CImageView drawing
- void CImageView::OnDraw(CDC* pDC)
- {
- // TODO: add draw code here
- CMyDoc* 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);//把DIB的部分区域或整张图画在DC中,originx和originy是目的地的左上角坐标
- //biWidth和biHeight是欲显示的矩形区域的宽度和高度,欲显示的矩形区域的左上角的起点是(0,0),第一条扫描线的起点是0,pBitmapData是DIB阵列
- //的指针,lpBitmapInfo是DIB信息的指针,DIB_RGB_COLORS是使用的颜色方式
- }
- /////////////////////////////////////////////////////////////////////////////
- // CImageView diagnostics
- #ifdef _DEBUG
- void CImageView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CImageView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CMyDoc* CImageView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
- return (CMyDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CImageView message handlers
- BOOL CImageView::PreCreateWindow(CREATESTRUCT& cs)
- {
- cs.cy = cs.cx =0;
- return CView::PreCreateWindow(cs);
- }