📄 ptapi.h
字号:
// Copyright(C) 2002-2007, 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.
// PtQREncode QR Code symbol writing.
// PtQRDecdoe QR Code symbol reading.
// PtDMEncode Data Matrix symbol writing.
// PtDMDecode Data Matrix symbol reading.
//======================================================================================
//
// Version: 2.0
//
// Date: 07 November 2005
// ======================================================================================
#ifndef _PT_API_H
#define _PT_API_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#pragma pack(8) // 8 bytes alignment
#ifndef BYTE
#define BYTE unsigned char
#endif
#ifndef WORD
#define WORD unsigned short
#endif
#ifndef DWORD
#define DWORD unsigned long
#endif
// * **********************************************************
// * Image file reading/writing APIs and definitions.
// * **********************************************************
/*----------------------------------------------------------------------------------------+
| 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.*/
void PtInitImage
(
PTIMAGE* pImage //Pointer to a PTIMAGE structure.
);
/*Load an image from a file*/
int PtLoadImage
(
const char* FileName, //Name of the file.
PTIMAGE* pImage, //Pointer to a PTIMAGE structure.
DWORD dwFrameIndex //The index of the frame wanted to load(start from 0).Some image files contain multi-frames, such as tiff file.
);
/*Save an image to a file*/
int PtSaveImage
(
const char* FileName, //Name of the file
PTIMAGE* pImage //Pointer to a PTIMAGE structure.
);
/*Allocate the memory for data and palette*/
int 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.*/
void PtFreeImage
(
PTIMAGE* pImage //Pointer to a PTIMAGE structure.
);
/*Get the frames of an image file. Some image files contain multi-frames, such as tiff file.*/
int PtGetImageFrames
(
const char* FileName //Name of the file.
);
// * **********************************************************
// * PDF417 symbol writing APIs and definitions
// * **********************************************************
/*--------------------------------------------------------------------------------------+
| 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. |
+--------------------------------------------------------------------------------------*/
/*Verify the licnese key for the engine.*/
int PtPDF417EncodeRegister
(
char* pKeyStr //Pointer to the string of license key.
);
/*Initialize the PTPDF417ENCODE structure with default values.*/
void PtPDF417EncodeInit
(
PTPDF417ENCODE* pEncode //Pointer to a PTPDF417ENCODE structure.
);
/*Encode a PDF417 symbol and then generate an image.*/
int 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.*/
int 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
// * **********************************************************
/*--------------------------------------------------------------------------------------+
| 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.
DWORD dwMaxCount; //The maximal number of symbols to be searched. If it's set to 0 then search the all symbols.
} 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. |
+--------------------------------------------------------------------------------------*/
/*Verify the licnese key for the engine.*/
int PtPDF417DecodeRegister
(
char* pKeyStr //Pointer to the string of license key.
);
/*Initialize the PTTOTALBARCODEINFO structure.*/
void PtPDF417DecodeInit
(
PTTOTALBARCODEINFO* pInfo //Pointer to a PTTOTALBARCODEINFO structure.
);
/*Decode PDF417 barcode from an image.*/
int PtPDF417Decode
(
PTIMAGE* pImage, //Pointer to a PTIMAGE structure.
PTDECODEPARA* pPara, //Pointer to a PTDECODEPARA structure
PTTOTALBARCODEINFO* pInfo //Pointer to a PTTOTALBARCODEINFO structure.
);
/*Decode PDF417 barcode from an image file. The function supports multiframes image, such as tiff*/
int PtPDF417DecodeFromFile
(
const char* FileName, //Name of the image file.
PTDECODEPARA* pPara, //Pointer to a PTDECODEPARA structure.
PTTOTALBARCODEINFO* pInfo //Pointer to a PTTOTALBARCODEINFO structure.
);
/*Free the memory allocated in the function PtPDF417Decode.*/
void PtPDF417DecodeFree
(
PTTOTALBARCODEINFO* pInfo //Pointer to a PTTOTALBARCODEINFO structure.
);
// * **********************************************************
// * QR Code symbol writing APIs and definitions
// * **********************************************************
/*--------------------------------------------------------------------------------------+
| DEFINES SECTION |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -