www.pudn.com > PKEncodeDemo.zip > PtAPI.h
// Copyright(C) 2002-2007, PDF417Kit & PartiTek Inc. All rights reserved.
//
// Title: PtAPI.h
//======================================================================================
//
// Description: Include file for the PartiTek Inc. API and definitions.
// The modules included are:
//
// PtImageRW Image file reading/writing.
// PtPDF417Encode PDF417 symbol writing.
// PtPDF417Decode PDF417 symbol reading.
//======================================================================================
//
// The following symbols control inclusion of various parts of this file:
//
// #define: To enable inclusion of:
// PT_PDF417_ENCODE PDF417 symbol writing APIs and definitions
// PT_PDF417_DECODE PDF417 symbol reading APIs and definitions
//
// ======================================================================================
//
// Version: 2.0
//
// Date: 07 November 2004
// ======================================================================================
#ifndef _PT_API_H
#define _PT_API_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#pragma pack(8) // 8 bytes alignment
#if !defined( WINAPI )
#define WINAPI PASCAL
#endif
// * **********************************************************
// * Image file reading/writing APIs and definitions.
// * **********************************************************
#if !defined( PT_IMAGERW_API )
#define PT_IMAGERW_API __declspec( dllimport )
#endif
/*----------------------------------------------------------------------------------------+
| DEFINES SECTION |
+----------------------------------------------------------------------------------------*/
/* Status of an operation */
#define PT_IMAGERW_FAIL 0x00000000 //An error occurred in an operation.
#define PT_IMAGERW_SUCCESS 0x00000001 //An operation is successful.
#define PT_IMAGERW_ALLOC_ERROR 0x00000100 //Error while allocating memory.
#define PT_IMAGERW_FORMAT_UNSUPPORTED 0x00000101 //The format of image is unsupported.
/*----------------------------------------------------------------------------------------+
| STRUCTURES SECTION |
| Please refer to the SDK manul for more detail. |
+-----------------------------------------------------------------------------------------*/
//The PTIMAGE structure contains the image information.
typedef struct tagPTIMAGE
{
DWORD dwWidth; //The width of the image in pixels.
DWORD dwHeight; //The height of the image in pixels.
unsigned char* pBits; //Pointer to the image data.
unsigned char* pPalette; //Pointer to the palette data (RGBQUAD)for 1,4,8 bits image.
WORD wBitsPerPixel; //Number of bits per pixel.
}PTIMAGE, *pPTIMAGE;
/*---------------------------------------------------------------------------------------+
| FUNCTIONS SECTION |
| Please refer to the SDK manul for more detail. |
+---------------------------------------------------------------------------------------*/
/*Initialize the PTIMAGE structure.*/
PT_IMAGERW_API void WINAPI PtInitImage
(
PTIMAGE* pImage //Pointer to a PTIMAGE structure.
);
/*Load an image from a file*/
PT_IMAGERW_API int WINAPI PtLoadImage
(
const char* FileName, //Name of the file.
PTIMAGE* pImage //Pointer to a PTIMAGE structure.
);
/*Save an image to a file*/
PT_IMAGERW_API int WINAPI PtSaveImage
(
const char* FileName, //Name of the file
PTIMAGE* pImage //Pointer to a PTIMAGE structure.
);
/*Display an image with the hDC.*/
PT_IMAGERW_API void WINAPI PtShowImage
(
PTIMAGE* pImage, //Pointer to a PTIMAGE structure.
HDC hDc, //Contains a handle of a window's device context to display the image.
int StartX, //The x-coordinate in pixels, of the upper-left corner of the destination rectangle.
int StartY, //The y-coordinate in pixels, of the upper-left corner of the destination rectangle.
float scale //Used to stretch or compress the image.
);
/*Allocate the memory for data and palette*/
PT_IMAGERW_API int WINAPI PtCreateImage
(
PTIMAGE* pImage, //Pointer to a PTIMAGE structure.
DWORD ImageSize, //The data dimension in byte.
DWORD PaletteSize //The palette dimension in byte.
);
/*Free the memory allocated by the engine in PtLoadImage or PtCreateImage function.*/
PT_IMAGERW_API void WINAPI PtFreeImage
(
PTIMAGE* pImage //Pointer to a PTIMAGE structure.
);
// * **********************************************************
// * PDF417 symbol writing APIs and definitions
// * **********************************************************
#if !defined( PT_PDF417ENCODE_API )
#define PT_PDF417ENCODE_API __declspec( dllimport )
#endif
/*--------------------------------------------------------------------------------------+
| DEFINES SECTION |
+--------------------------------------------------------------------------------------*/
/* Status of an operation */
#define PT_PDF417ENCODE_FAIL 0x00000000 //An operation is Failed.
#define PT_PDF417ENCODE_SUCCESS 0x00000001 //An operation is successful.
#define PT_PDF417ENCODE_ALLOC_ERROR 0x00000200 //Error while allocating the memory.
#define PT_PDF417ENCODE_DATA_BIG 0x00000201 //Data to be encoded is too big.
#define PT_PDF417ENCODE_SIZE_SMALL 0x00000202 //The size of image to be pasted the symbol is too small.
#define PT_PDF417ENCODE_IMAGE_INVALID 0x00000203 //The image to be pasted is invalid.
/* PDF417 ECC level constants */
#define PT_PDF417_ECCLEVEL_0 0x0000 //Use ECC level 0. This uses 2 codewords for error correction.
#define PT_PDF417_ECCLEVEL_1 0x0001 //Use ECC level 1. This uses 4 codewords for error correction.
#define PT_PDF417_ECCLEVEL_2 0x0002 //Use ECC level 2. This uses 8 codewords for error correction.
#define PT_PDF417_ECCLEVEL_3 0x0003 //Use ECC level 3. This uses 16 codewords for error correction.
#define PT_PDF417_ECCLEVEL_4 0x0004 //Use ECC level 4. This uses 32 codewords for error correction.
#define PT_PDF417_ECCLEVEL_5 0x0005 //Use ECC level 5. This uses 64 codewords for error correction.
#define PT_PDF417_ECCLEVEL_6 0x0006 //Use ECC level 6. This uses 128 codewords for error correction.
#define PT_PDF417_ECCLEVEL_7 0x0007 //Use ECC level 7. This uses 256 codewords for error correction.
#define PT_PDF417_ECCLEVEL_8 0x0008 //Use ECC level 8. This uses 512 codewords for error correction.
#define PT_PDF417_ECC_PERCENT 0x0009 //Use the percentage to determine the ECC level.
/*--------------------------------------------------------------------------------------+
| STRUCTURES SECTION |
| Please refer to the SDK manul for more detail. |
+---------------------------------------------------------------------------------------*/
/*The PTPDF417ENCODE structure contains the information related to PDF417 barcodes*/
typedef struct tagPTPDF417ENCODE
{
char* pData; //Pointer to the data to be encoded.
int nDataLength; //Length of the data in bytes.
int bIsTruncated; //Writes truncated PDF417 symbols or not.
WORD wEccPercent; //Determines the error correction level by percentage.
WORD wEccLevel; //Determines the ECC level for encoding a PDF417 symbol.
WORD wCols; //Number of columns in the symbol.
WORD wRows; //Number of rows in the symbol.
WORD wAspectHeigh; //The height part of the aspect ratio of the symbol.
WORD wAspectWidth; //The width part of the aspect ratio of the symbol.
WORD wXModule; //The smallest element width in pixels.
WORD wModuleAspectRatio;//The ratio of a row height to XModule .
WORD wLeftSpace; //The left space of the symbol in pixels while generating the image.
WORD wRightSpace; //The right space of the symbol in pixels while generating the image.
WORD wTopSpace; //The top space of the symbol in pixels while generating the image.
WORD wBottomSpace; //The bottom space of the symbol in pixels while generating the image.
}PTPDF417ENCODE, *pPTPDF417ENCODE;
/*--------------------------------------------------------------------------------------+
| FUNCTIONS SECTION |
| Please refer to the SDK manul for more detail. |
+--------------------------------------------------------------------------------------*/
/*Initialize the PTPDF417ENCODE structure with default values.*/
PT_PDF417ENCODE_API void WINAPI PtPDF417EncodeInit
(
PTPDF417ENCODE* pEncode //Pointer to a PTPDF417ENCODE structure.
);
/*Encode a PDF417 symbol and then generate an image.*/
PT_PDF417ENCODE_API int WINAPI PtPDF417Encode
(
PTPDF417ENCODE* pEncode, //Pointer to a PTPDF417ENCODE structure.
PTIMAGE* pImage //Pointer to a PTIMAGE structure.
);
/*Encode a PDF417 symbol and then paste the symbol to an existing image.*/
PT_PDF417ENCODE_API int WINAPI PtPDF417EncodeToImage
(
PTPDF417ENCODE* pEncode, //Pointer to a PTPDF417ENCODE structure.
PTIMAGE* pDstImg, //Pointer to a PTIMAGE structure.
int StartX, //The x-coordinate in pixels, of the upper-left corner of the destination rectangle.
int StartY //The y-coordinate in pixels, of the upper-left corner of the destination rectangle.
);
// * **********************************************************
// * PDF417 symbol reading APIs and definitions
// * **********************************************************
#if !defined( PT_PDF417DECODE_API )
#define PT_PDF417DECODE_API __declspec( dllimport )
#endif
/*--------------------------------------------------------------------------------------+
| DEFINES SECTION |
+--------------------------------------------------------------------------------------*/
/* Status of an operation */
#define PT_PDF417DECODE_FAIL 0x00000000//An error occurred in an operation.
#define PT_PDF417DECODE_SUCCESS 0x00000001//An operation is successful.
#define PT_PDF417DECODE_ALLOC_ERROR 0x00000300//Error while allocating the memory.
#define PT_PDF417DECODE_IMAGE_INVALID 0x00000301//The image to be decode is invalid.
#define PT_PDF417DECODE_PARAMETERS_INVALID 0x00000302//The parameters input to a function are invalid.
/*--------------------------------------------------------------------------------------+
| STRUCTURES SECTION |
| Please refer to the SDK manul for more detail. |
+---------------------------------------------------------------------------------------*/
/*The PTDECODEPARA structure is used to decide parameter when decoding barcodes from an image.*/
typedef struct tagPTDECODEPARA
{
DWORD dwStartX; //The start X-coordinate in pixels of the search window in the image to decode the symbol.
DWORD dwStartY; //The start Y-coordinate in pixels of the search window in the image to decode the symbol.
DWORD dwEndX; //The end X-coordinate in pixels of the search window in the image to decode the symbol.
DWORD dwEndY; //The end Y-coordinate in pixels of the search window in the image to decode the symbol.
} PTDECODEPARA, *pPTDECODEPARA
;
/*The PTBARCODEINFO structure contains a barcode information after decoding*/
typedef struct tagPTBARCODEINFO
{
DWORD dwX1, dwY1; //Four corners' coordinates in pixels of the barcode.
DWORD dwX2, dwY2;
DWORD dwX3, dwY3;
DWORD dwX4, dwY4;
BYTE* pData; //Pointer to the buffer that contains the barcode's data.
DWORD dwDataLen; //The barcode data's length in bytes.
}PTBARCODEINFO, *pPTBARCODEINFO
;
/*The PTTOTALBARCODEINFO structure contains all barcodes' information after decoding*/
typedef struct tagPTTOTALBARCODEINFO
{
PTBARCODEINFO* pInfoList; //Pointer to the start address of the list of barcodes' info.
DWORD dwTotalCount; //The number of barcode that have been decoded.
}PTTOTALBARCODEINFO, *pPTOTALBARCODEINFO
;
/*--------------------------------------------------------------------------------------+
| FUNCTIONS SECTION |
| Please refer to the SDK manul for more detail. |
+--------------------------------------------------------------------------------------*/
/*Initialize the PTTOTALBARCODEINFO structure.*/
PT_PDF417DECODE_API void WINAPI PtPDF417DecodeInit
(
PTTOTALBARCODEINFO* pInfo //Pointer to a PTTOTALBARCODEINFO structure.
);
/*Decode PDF417 barcode from an image.*/
PT_PDF417DECODE_API int WINAPI PtPDF417Decode
(
PTIMAGE* pImage, //Pointer to a PTIMAGE structure.
PTDECODEPARA* pPara, //Pointer to a PTDECODEPARA structure
PTTOTALBARCODEINFO* pInfo //Pointer to a PTTOTALBARCODEINFO structure.
);
/*Free the memory allocated in the function PtPDF417Decode.*/
PT_PDF417DECODE_API void WINAPI PtPDF417DecodeFree
(
PTTOTALBARCODEINFO* pInfo //Pointer to a PTTOTALBARCODEINFO structure.
);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif