www.pudn.com > QRAPPuie.rar > QRAPI.h


 
/*// QRAPI.h : main header file for the QRAPI DLL 
// 
 
#pragma once 
 
#ifndef __AFXWIN_H__ 
	#error "include 'stdafx.h' before including this file for PCH" 
#endif 
 
#include "resourceppc.h" 
 
// CQRAPIApp 
// See QRAPI.cpp for the implementation of this class 
// 
 
class CQRAPIApp : public CWinApp 
{ 
public: 
	CQRAPIApp(); 
 
// Overrides 
public: 
	virtual BOOL InitInstance(); 
 
	DECLARE_MESSAGE_MAP() 
}; 
 
*/ 
/********************************************************************************  
 *  QRAPI.H 
 *  
 *  Header file for QR code image processing API.  Provides  
 *  function prototypes and constants for QR code imge processing functions  
 ********************************************************************************/  
 
#ifndef __QRAPI_H_ 
#define __QRAPI_H_ 
 
//HANDLE to a QR image 
#define HQRIMG HANDLE 
 
/* QR image constants */  
#define QRPALVERSION			0x300  
 
//ERROR CORRECTION LEVEL 
#define LEVEL_M			0 
#define LEVEL_L     1 
#define LEVEL_H			2 
#define LEVEL_Q			3 
/* Gray Method */ 
#define QRMEAN_GRAY				0 
#define QRMAXIMUM_GRAY		1 
#define QRWEIGHT_GRAY			2 
 
// Filter algorithm 
#define QRFILTER1				1 
#define QRFILTER2				2 
#define QRFILTER3				3 
 
// Edge enhancement algorithm 
#define QRVERT				1 
#define QRHORZ				2 
#define QRVERTHORZ			3 
#define QRNORTH				4 
#define QRNORTHEAST			5 
#define QREAST				6 
#define QRSOUTH				7 
#define QRSOUTHEAST			8 
#define QRSOUTHWEST			9 
#define QRWEST				10 
#define QRNORTHWEST			11 
#define QRLAP1				12 
#define QRLAP2				13 
#define QRLAP3				14 
#define QRLAP4				15 
#define QRSOBEL				16 
#define QRHOUGH				17 
 
// 
#define QRWIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)  
#define QRBOUND(x, mn, mx)	((x) < (mn) ? (mn) : ((x) > (mx) ? (mx) : (x))) 
#define IS_WIN30_QR(lpbi)  ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))  
#define QRWaitCursorBegin()	HCURSOR hcURSOR = SetCursor(LoadCursor(NULL, IDC_WAIT)) 
#define QRWaitCursorEnd()		SetCursor(hcURSOR)  
 
 
// Definitions required for convolution image filtering 
// struct for convolute kernel  
#define QRKERNELCOLS 3 
#define QRKERNELROWS 3 
#define QRKERNELELEMENTS (QRKERNELCOLS * QRKERNELROWS) 
#define PIXEL_OFFSET(i, j, nWidthBytes)	\ 
		(LONG)((LONG)(i)*(LONG)(nWidthBytes) + (LONG)(j)*3) 
 
#define MAXMUM_VERSION 177 
#define MAXMUM_SEGMENT 50 
#define LINE_MAX	1000 
typedef struct  
{ 
  int Element[QRKERNELELEMENTS]; 
  int Divisor; 
} QRKERNEL; 
 
//Change QR image color table from color to grayscale 
//HPALETTE ConvertToGrayscale(HQRIMG hDib, int nMethod, double fRedWeight, double fGreenWeight, double fBlueWeight); 
 
//gets the bit count of the QR image from the LPBITMAPINFOHEADER 
WORD QRBitCount(HQRIMG hDIB); 
WORD QRBitCount(LPBYTE lpDIB); 
 
//Copy memory handle to another 
HANDLE CopyQRHandle(HANDLE h); 
 
//calculates the address of the QR image's bits and returns a pointer to the QR image bits 
LPBYTE FindQRBits(LPBYTE lpDIB); 
 
//gets the height of the QR image from the BITMAPINFOHEADER 
DWORD QRHeight(HQRIMG hDIB); 
DWORD QRHeight(LPBYTE lpDIB); 
 
//gets the width of the QR image from the BITMAPINFOHEADER 
DWORD QRWidth(HQRIMG hDIB); 
DWORD QRWidth(LPBYTE lpDIB); 
 
//Calculates the number of bytes in one scan line 
DWORD QRBytesPerLine(HQRIMG hDIB); 
DWORD QRBytesPerLine(LPBYTE lpDIB); 
 
WORD QRNumColors(HQRIMG hDIB); 
WORD QRNumColors(LPBYTE lpDIB); 
 
WORD QRPaletteSize(HQRIMG hDIB); 
WORD QRPaletteSize(LPBYTE lpDIB); 
 
DWORD QRBlockSize(HQRIMG hDIB); 
DWORD QRBlockSize(LPBYTE lpDIB); 
 
// local function prototype 
int QRcompare(const void *e1, const void *e2); 
//Median filter to QR image 
BOOL MedianFilterQR(HQRIMG hDib); 
void DoMedianFilterQR(int *red, int *green, int *blue, int i, int j,WORD wBytesPerLine, LPBYTE lpDIBits); 
//Convolute QR image 
BOOL ConvoluteQR(HQRIMG hDib, QRKERNEL *lpKernel, int Strength, int nKernelNum=1); 
void DoConvoluteQR(int *red, int *green, int *blue, int i, int j,WORD wBytesPerLine, LPBYTE lpDIBits, QRKERNEL *lpKernel); 
//high pass filter to QR image 
BOOL HighPassQR(HQRIMG hDib, int Strength, int nAlgorithm); 
//low pass filter to QR image 
BOOL LowPassQR(HQRIMG hDib, int Strength, int nAlgorithm); 
//Enhance edge to QR image 
BOOL EdgeEnhanceQR(HQRIMG hDib, int Strength, int nDirection); 
 
//to get the histogram from 256 color QR image 
void Histogram(HQRIMG hDib,long *Graytable,long *DifGrayTable); 
unsigned char DoDifferential(LPSTR lpPtr,DWORD LineBytes); 
int QRABS(int str1,int str2); 
BOOL Erzhihua(HQRIMG hDib); 
//to convert QR image to gray scale 
HPALETTE ConvertQRToGrayscale(HQRIMG hDib, int nMethod,  
				double fRedWeight, double fGreenWeight, double fBlueWeight); 
 
//////////////////////////////////////////////////////// 
//find the orientation  image 
typedef struct  
{ 
  int x; 
  int y; 
} ORIENTATIONCENTER; 
 
enum Rotate { 
			ANTICLOCKWISE, 
			HALFCIRCLE, 
			NOACTION, 
			CLOCKWISE 
			}; 
//to rotate the index image 
BOOL RotateIndexImage(HGLOBAL hIndexData,Rotate RotageAngle,int row,int column); 
 
//HPALETTE           hQRPalette=NULL; 
BOOL PositionDetectImage(HQRIMG hDib,int *dim); 
//to get the version number information							 
 unsigned char VersionNumberInfo(HGLOBAL hIndexData,int row,int column); 
//to get the format information including the error correction level and mask reference 
 unsigned char FormatInfo(HGLOBAL hIndexData,int row,int column); 
// to get the amount of revise images and the position of very revise image center; 
 unsigned char ReviseimagePos(unsigned char VersionNum); 
 BOOL MaskImg(unsigned char FormatNum,unsigned char VersionNum); 
//unmask the index image to get the original code  
// BOOL UnmaskIndexImage(HGLOBAL hIndexData,HGLOBAL hMaskImg,HGLOBAL hMarkImage,unsigned char VersionNum); 
  BOOL UnmaskIndexImage(HGLOBAL hIndexData,unsigned char VersionNum,unsigned char Format); 
//to mark the functional images of QR index image,including version number information, 
//format information, position detect images and revise images.  
 BOOL MarkImage(unsigned char VersionNum); 
//to get the correction code including amount of the correct module and the correction code 
 BOOL GetCorrectionCode(unsigned char VersionNum,unsigned char Format,unsigned char CorrectCode[5]); 
//to get the origianl code 
 HGLOBAL GetOriginalCode(HGLOBAL hIndexData,unsigned char VersionNum,unsigned char Format); 
//to devide the original code to several segment. according to the mode rule to decode every 
//segment  
 int QRDecoder(HGLOBAL hOriginalCode,unsigned char VersionNum,unsigned char Format); 
// to get the bit digit of character counter, according mode and version number; 
unsigned char GetModeCountBit(unsigned char VersionNum,unsigned char mode); 
//to translate the character-number to GB2312 chatater 
unsigned short TranslateChaNum(unsigned char chanum); 
int Round(double Y); 
BOOL Correct_Code(HGLOBAL hOriginalCode, unsigned char CorrectCode[]); 
HGLOBAL GetDecodeData(unsigned short *codenum,unsigned char VersionNum,unsigned char Format); 
HGLOBAL GetIndexImage(); 
HGLOBAL GetMaskImg(); 
HGLOBAL GetMarkImg(); 
BOOL ToUnmaskIndexImg(unsigned char VersionNum,unsigned char Format); 
unsigned char BCH_ERROR_FORMAT(unsigned int Format); 
/* 
//to difine some global variables  
HGLOBAL hIndexData=NULL; 
HGLOBAL hMaskImg=NULL; 
HGLOBAL hMarkImage=NULL; 
HGLOBAL hOriginalCode=NULL; 
HGLOBAL hDecodeData=NULL; 
// local use macro 
 
ORIENTATIONCENTER TopLeft={0,0}; 
ORIENTATIONCENTER TopRight={0,0}; 
ORIENTATIONCENTER BottomLeft={0,0}; 
 
unsigned char ReviseImgPos[8];//[5] is the number of coordinate.  
unsigned char VersionNum=0; 
unsigned int  Format=0U; 
*/ 
#endif