Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

High performance computing from C++ to MMX

, 30 Jul 2003
Boosting you application performance to the optimum by using hardware acceleration.
// MiniView.cpp : implementation file
//

#include "stdafx.h"
#include "mmxdemo.h"
#include "MiniView.h"
#include "mmxdemodoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMiniView

IMPLEMENT_DYNCREATE(CMiniView, CScrollView)

CMiniView::CMiniView()
{
	// 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;
	}
}

CMiniView::~CMiniView()
{
}


BEGIN_MESSAGE_MAP(CMiniView, CScrollView)
	//{{AFX_MSG_MAP(CMiniView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMiniView drawing

void CMiniView::OnInitialUpdate()
{
	CMMXDemoDoc* pDoc = (CMMXDemoDoc* )GetDocument();
	CScrollView::OnInitialUpdate();

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	sizeTotal.cx = pDoc->m_iWidth;
	sizeTotal.cy = pDoc->m_iHeight;
	SetScrollSizes(MM_TEXT, sizeTotal);
}

void CMiniView::OnDraw(CDC* pDC)
{
	CMMXDemoDoc* pDoc = (CMMXDemoDoc* )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);
	pDC->TextOut(10, 10, m_szText);
}

/////////////////////////////////////////////////////////////////////////////
// CMiniView diagnostics

#ifdef _DEBUG
void CMiniView::AssertValid() const
{
	CScrollView::AssertValid();
}

void CMiniView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMiniView message handlers
void CMiniView::SetScrollingWindow(int dx, int dy)
{
	CMMXDemoDoc* pDoc = (CMMXDemoDoc*) GetDocument();
	CSize sizeTotal;

	// TODO: calculate the total size of this view
	sizeTotal.cx = dx;
	sizeTotal.cy = dy;
	SetScrollSizes(MM_TEXT, sizeTotal);

	Invalidate();
}

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Vincent Leong77
Web Developer Cortex Imaging
Malaysia Malaysia
Interest in computer vision, biometrics, image processing & software optimizations. Known language C/C++, VC++ MFC, Win32, COM/ATL, Assembly.

| Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 31 Jul 2003
Article Copyright 2003 by Vincent Leong77
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid