|
// MMXDemoView.cpp : implementation of the CMMXDemoView class
//
#include "stdafx.h"
#include "MMXDemo.h"
#include "MMXDemoDoc.h"
#include "MMXDemoView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMMXDemoView
IMPLEMENT_DYNCREATE(CMMXDemoView, CScrollView)
BEGIN_MESSAGE_MAP(CMMXDemoView, CScrollView)
//{{AFX_MSG_MAP(CMMXDemoView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMMXDemoView construction/destruction
CMMXDemoView::CMMXDemoView()
{
// TODO: add construction code here
m_pImg = NULL;
DWORD bitmapInfoSize,i;
// Bitmap info structure for the image
bitmapInfoSize = sizeof(BITMAPINFO) + 255*sizeof(RGBQUAD);
m_pBmiImage = (BITMAPINFO*)new BYTE[bitmapInfoSize];
m_pBmiImage->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
m_pBmiImage->bmiHeader.biPlanes = 1;
m_pBmiImage->bmiHeader.biBitCount = 8;
m_pBmiImage->bmiHeader.biCompression = BI_RGB;
m_pBmiImage->bmiHeader.biSizeImage = 0;
m_pBmiImage->bmiHeader.biXPelsPerMeter = 0;
m_pBmiImage->bmiHeader.biYPelsPerMeter = 0;
m_pBmiImage->bmiHeader.biClrUsed = 0;
m_pBmiImage->bmiHeader.biClrImportant = 0;
m_pBmiImage->bmiHeader.biWidth = 0;
m_pBmiImage->bmiHeader.biHeight = 0;
for (i = 0 ; i < 256 ; i++) {
m_pBmiImage->bmiColors[i].rgbBlue = (BYTE)i;
m_pBmiImage->bmiColors[i].rgbGreen = (BYTE)i;
m_pBmiImage->bmiColors[i].rgbRed = (BYTE)i;
m_pBmiImage->bmiColors[i].rgbReserved = 0;
}
}
CMMXDemoView::~CMMXDemoView()
{
}
BOOL CMMXDemoView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMMXDemoView drawing
void CMMXDemoView::OnDraw(CDC* pDC)
{
CMMXDemoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (m_pImg == NULL)
return;
// Set bitmap header info
m_pBmiImage->bmiHeader.biWidth = pDoc->m_iWidth;
m_pBmiImage->bmiHeader.biHeight = -pDoc->m_iHeight;
// Display
SetDIBitsToDevice(pDC->GetSafeHdc(),
0, 0, pDoc->m_iWidth, pDoc->m_iHeight,
0, 0, 0, pDoc->m_iHeight,
m_pImg, m_pBmiImage, DIB_RGB_COLORS);
// Display timing
CString szTime;
szTime.Format("Time = %.3fms", pDoc->m_el.m_dElapsed*1000);
pDC->TextOut(10, 10, szTime);
}
void CMMXDemoView::OnInitialUpdate()
{
CMMXDemoDoc* pDoc = GetDocument();
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = pDoc->m_iWidth;
sizeTotal.cy = pDoc->m_iHeight;
// Select the source buffer pointer
m_pImg = pDoc->m_pImg;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CMMXDemoView diagnostics
#ifdef _DEBUG
void CMMXDemoView::AssertValid() const
{
CScrollView::AssertValid();
}
void CMMXDemoView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CMMXDemoDoc* CMMXDemoView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMMXDemoDoc)));
return (CMMXDemoDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMMXDemoView message handlers
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Interest in computer vision, biometrics, image processing & software optimizations. Known language C/C++, VC++ MFC, Win32, COM/ATL, Assembly.