www.pudn.com > Barcode_src.zip > Barcode.cpp


// Barcode.cpp: implementation of the CBarcode class. 
// 
//	Copyright 2002 Neil Van Eps 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "Barcode.h" 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CBarcode::CBarcode() 
{ 
 
} 
 
CBarcode::~CBarcode() 
{ 
 
} 
 
//////////////////////////////////////////////////////////////////////////////////// 
// 
//	Name: 
//		LoadData() 
// 
//	Description: 
// 
// 
//	Arguments: 
// 
// 
//	Return: 
// 
// 
//	Called by: 
// 
// 
//////////////////////////////////////////////////////////////////////////////////// 
 
void CBarcode::LoadData(CString csMessage, double dNarrowBar, double dFinalHeight, HDC pDC, int nStartingXPixel, int nStartingYPixel, double dRatio ) 
{ 
	int		i,nXAxisDpi,nYAxisDpi,nTemp; 
	char	c; 
	 
	// values that can be saved without translation 
	m_csMessage = csMessage; 
	m_nStartingXPixel = nStartingXPixel; 
	m_nStartingYPixel = nStartingYPixel; 
	m_hDC = pDC; 
 
	// calculate X and Y Axis dots per inch 
	if (m_hDC==NULL) 
	{ 
		CDC		memDC; 
 
		// create the memory device context - will be compatible with the screen 
		memDC.CreateCompatibleDC(NULL); 
 
		// get dpi for the two axes 
		nXAxisDpi = memDC.GetDeviceCaps(LOGPIXELSX); 
		nYAxisDpi = memDC.GetDeviceCaps(LOGPIXELSY); 
	} 
	else 
	{ 
		CDC		tempDC; 
 
		tempDC.Attach(m_hDC); 
 
		nXAxisDpi = tempDC.GetDeviceCaps(LOGPIXELSX); 
		nYAxisDpi = tempDC.GetDeviceCaps(LOGPIXELSY); 
 
		tempDC.Detach(); 
	} 
 
	// load the final attributes that depend on the device context 
	m_nPixelHeight = (int)((nYAxisDpi*dFinalHeight)+0.5); 
	m_nNarrowBarPixelWidth = (int)((nXAxisDpi*dNarrowBar)+0.5); 
	m_nWideBarPixelWidth = (int)(dRatio*m_nNarrowBarPixelWidth); 
 
	switch (m_nSymbology) 
	{ 
		case RATIONALCODABAR: 
			// initialize to zero 
			m_nFinalBarcodePixelWidth = 0; 
 
			// add the width of each character 
			for (i=0;i