www.pudn.com > PKEncodeDemo.zip > PtEncode.bas


Attribute VB_Name = "PtEncode" 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
''Image file reading/writing APIs and definitions 
'DEFINES SECTION 
Public Const PT_IMAGERW_FAIL = &H0                    'An error occured in an operation. 
Public Const PT_IMAGERW_SUCCESS = &H1                 'An operation is successful. 
Public Const PT_IMAGERW_ALLOC_ERROR = &H100           'Error while allocating memory. 
Public Const PT_IMAGERW_FORMAT_UNSUPPORTED = &H101    'The format of image is unsupported. 
     
'STRUCTURES SECTION 
'The PTIMAGE structure contains the image information. 
Type PTIMAGESTRUCT 
    dwWidth As Long           'The width of the image in pixels. 
    dwHeight As Long          'The height of the image in pixels. 
    pBits As Long             'Pointer to the image data. 
    pPalette As Long          'Pointer to the palette data (RGBQUAD)for 1,4,8 bit image. 
    wBitsPerPixel As Integer  'Number of bits per pixel. 
End Type 
     
'FUNCTIONS SECTION 
Public Declare Sub PtInitImage Lib "PtImageRW" (pImage As PTIMAGESTRUCT) 
Public Declare Sub PtFreeImage Lib "PtImageRW" (pImage As PTIMAGESTRUCT) 
Public Declare Function PtLoadImage Lib "PtImageRW" (ByVal fileName As String, pImage As PTIMAGESTRUCT) As Long 
Public Declare Function PtSaveImage Lib "PtImageRW" (ByVal fileName As String, pImage As PTIMAGESTRUCT) As Long 
Public Declare Function PtCreateImage Lib "PtImageRW" (pImage As PTIMAGESTRUCT, ByVal ImageSize As Long, ByVal PaletteSize As Long) As Long 
     
     
''PDF417 symbol writing APIs and definitions. 
'DEFINES SECTION 
Public Const PT_PDF417ENCODE_FAIL = &H0            'An operation is Failed. 
Public Const PT_PDF417ENCODE_SUCCESS = &H1         'An operation is successful. 
Public Const PT_PDF417ENCODE_ALLOC_ERROR = &H200   'Error while allocating the memory. 
Public Const PT_PDF417ENCODE_DATA_BIG = &H201      'Data to be encoded is too big. 
Public Const PT_PDF417ENCODE_SIZE_SMALL = &H202    'The size of image to be pasted the symbol is too small. 
Public Const PT_PDF417ENCODE_IMAGE_INVALID = &H203 'The image to be pasted is invalid. 
 
Public Const PT_PDF417_ECCLEVEL_0 = &H0         'Use ECC level 0. This uses 2   codewords for error correction. 
Public Const PT_PDF417_ECCLEVEL_1 = &H1         'Use ECC level 1. This uses 4   codewords for error correction. 
Public Const PT_PDF417_ECCLEVEL_2 = &H2         'Use ECC level 2. This uses 8   codewords for error correction. 
Public Const PT_PDF417_ECCLEVEL_3 = &H3         'Use ECC level 3. This uses 16  codewords for error correction. 
Public Const PT_PDF417_ECCLEVEL_4 = &H4         'Use ECC level 4. This uses 32  codewords for error correction. 
Public Const PT_PDF417_ECCLEVEL_5 = &H5         'Use ECC level 5. This uses 64  codewords for error correction. 
Public Const PT_PDF417_ECCLEVEL_6 = &H6         'Use ECC level 6. This uses 128 codewords for error correction. 
Public Const PT_PDF417_ECCLEVEL_7 = &H7         'Use ECC level 7. This uses 256 codewords for error correction. 
Public Const PT_PDF417_ECCLEVEL_8 = &H8         'Use ECC level 8. This uses 512 codewords for error correction. 
Public Const PT_PDF417_ECC_PERCENT = &H9        'Use the percentage to determine the ECC level. 
 
 
'STRUCTURES SECTION 
'The PTPDF417ENCODE structure contains the information related to PDF417 barcodes 
Type PTPDF417ENCODESTRUCT 
    pData As Long                  'Pointer to the data to be encoded. 
    nDataLength As Long            'Length of the data in bytes. 
    bIsTruncated As Long           'Writes truncated PDF417 symbols. 
    wEccPercent As Integer         'Determines the error correction level by percentage. 
    wEccLevel  As Integer          'Determines the ECC level for encoding a PDF417 symbol. 
    wCols  As Integer              'Number of columns in the symbol. 
    wRows As Integer               'Number of rows in the symbol. 
    wAspectHeigh As Integer        'The height part of the aspect ratio of the symbol. 
    wAspectWidth As Integer        'The width part of the aspect ratio of the symbol. 
    wXModule As Integer            'The smallest element width in pixels. 
    wModuleAspectRatio As Integer  'The ratio of a row height to XModule . 
    wLeftSpace As Integer          'The left   space of the symbol in pixels while generating Image. 
    wRightSpace As Integer         'The right  space of the symbol in pixels while generating Image. 
    wTopSpace As Integer           'The top    space of the symbol in pixels while generating Image. 
    wBottomSpace As Integer        'The bottom space of the symbol in pixels while generating Image. 
End Type 
 
 
'FUNCTIONS SECTION 
Public Declare Sub PtPDF417EncodeInit Lib "PtPDF417Encode" (pEncode As PTPDF417ENCODESTRUCT) 
Public Declare Function PtPDF417Encode Lib "PtPDF417Encode" (pEncode As PTPDF417ENCODESTRUCT, pImage As PTIMAGESTRUCT) As Long 
Public Declare Function PtPDF417EncodeToImage Lib "PtPDF417Encode" (pEncode As PTPDF417ENCODESTRUCT, pImage As PTIMAGESTRUCT, ByVal StartX As Long, ByVal StartY As Long) As Long 
 
 
 
Public Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As String, ByVal lpString2 As String) As Long 
Public Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long