home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{EF6969B1-01FE-4CE1-A234-66D7A60863F2}#1.0#0"; "NCTDataCompress.dll"
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
- Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
- Begin VB.Form frmDialog
- Caption = "Test VB 6.0 NCTDataCompress ActiveX Control"
- ClientHeight = 3285
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 5295
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3285
- ScaleWidth = 5295
- StartUpPosition = 2 'CenterScreen
- Begin MSComctlLib.ProgressBar ProgressBar1
- Height = 195
- Left = 0
- TabIndex = 24
- Top = 3060
- Width = 5235
- _ExtentX = 9234
- _ExtentY = 344
- _Version = 393216
- Appearance = 1
- End
- Begin VB.TextBox Text7
- Alignment = 1 'Right Justify
- Height = 315
- Left = 3780
- TabIndex = 23
- Text = "5"
- Top = 2160
- Width = 435
- End
- Begin MSComCtl2.UpDown UpDown4
- Height = 315
- Left = 4200
- TabIndex = 22
- Top = 2160
- Width = 240
- _ExtentX = 423
- _ExtentY = 556
- _Version = 393216
- Value = 5
- BuddyControl = "Text7"
- BuddyDispid = 196609
- OrigLeft = 4980
- OrigTop = 1860
- OrigRight = 5220
- OrigBottom = 2295
- Max = 12
- Min = 1
- SyncBuddy = -1 'True
- BuddyProperty = 65547
- Enabled = -1 'True
- End
- Begin MSComCtl2.UpDown UpDown3
- Height = 315
- Left = 2415
- TabIndex = 21
- Top = 2160
- Width = 240
- _ExtentX = 423
- _ExtentY = 556
- _Version = 393216
- Value = 10
- BuddyControl = "Text6"
- BuddyDispid = 196610
- OrigLeft = 2520
- OrigTop = 2340
- OrigRight = 2760
- OrigBottom = 2655
- Max = 40
- Min = 4
- SyncBuddy = -1 'True
- BuddyProperty = 65547
- Enabled = -1 'True
- End
- Begin VB.TextBox Text6
- Alignment = 1 'Right Justify
- Height = 315
- Left = 1620
- TabIndex = 20
- Text = "10"
- Top = 2160
- Width = 795
- End
- Begin VB.OptionButton Option2
- Caption = "BWT"
- Height = 255
- Left = 2460
- TabIndex = 17
- Top = 1440
- Width = 795
- End
- Begin VB.OptionButton Option1
- Caption = "PPM"
- Height = 255
- Left = 1620
- TabIndex = 16
- Top = 1440
- Value = -1 'True
- Width = 795
- End
- Begin VB.TextBox Text5
- Alignment = 1 'Right Justify
- Height = 315
- Left = 3780
- Locked = -1 'True
- TabIndex = 13
- Text = "1"
- Top = 1800
- Width = 435
- End
- Begin MSComCtl2.UpDown UpDown2
- Height = 315
- Left = 4200
- TabIndex = 14
- Top = 1800
- Width = 240
- _ExtentX = 423
- _ExtentY = 556
- _Version = 393216
- Value = 1
- BuddyControl = "Text5"
- BuddyDispid = 196613
- OrigLeft = 4380
- OrigTop = 1440
- OrigRight = 4620
- OrigBottom = 1785
- Max = 65535
- Min = 1
- SyncBuddy = -1 'True
- BuddyProperty = 65547
- Enabled = -1 'True
- End
- Begin VB.TextBox Text4
- Alignment = 1 'Right Justify
- Height = 315
- Left = 1620
- Locked = -1 'True
- TabIndex = 10
- Text = "1024"
- Top = 1800
- Width = 795
- End
- Begin MSComCtl2.UpDown UpDown1
- Height = 315
- Left = 2415
- TabIndex = 9
- Top = 1800
- Width = 240
- _ExtentX = 423
- _ExtentY = 556
- _Version = 393216
- Value = 1024
- BuddyControl = "Text4"
- BuddyDispid = 196614
- OrigLeft = 2580
- OrigTop = 1320
- OrigRight = 2820
- OrigBottom = 1605
- Increment = 10
- Max = 4096
- SyncBuddy = -1 'True
- BuddyProperty = 65547
- Enabled = -1 'True
- End
- Begin VB.TextBox Text3
- Height = 345
- Left = 1620
- TabIndex = 7
- Top = 960
- Width = 3075
- End
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 4680
- Top = 1440
- _ExtentX = 847
- _ExtentY = 847
- _Version = 393216
- End
- Begin VB.CommandButton UncompressButton
- Caption = "Uncompress"
- Height = 375
- Left = 2700
- TabIndex = 6
- Top = 2580
- Width = 2055
- End
- Begin VB.CommandButton CompressButton
- Caption = "Compress"
- Height = 375
- Left = 540
- TabIndex = 5
- Top = 2580
- Width = 2055
- End
- Begin VB.CommandButton Button1
- Caption = "..."
- Height = 315
- Left = 4800
- TabIndex = 4
- Top = 120
- Width = 315
- End
- Begin VB.TextBox Text2
- Height = 345
- Left = 1620
- TabIndex = 3
- Top = 540
- Width = 3075
- End
- Begin VB.TextBox Text1
- Height = 345
- Left = 1620
- TabIndex = 0
- Text = "Enter input file"
- Top = 120
- Width = 3075
- End
- Begin VB.Label Label8
- Caption = "PPMMemSize (mB):"
- Height = 255
- Left = 60
- TabIndex = 19
- Top = 2220
- Width = 1455
- End
- Begin VB.Label Label7
- Caption = "PPMOrder:"
- Height = 255
- Left = 2820
- TabIndex = 18
- Top = 2220
- Width = 915
- End
- Begin VB.Label Label6
- Caption = "Algorithm:"
- Height = 285
- Left = 60
- TabIndex = 15
- Top = 1440
- Width = 1155
- End
- Begin VB.Label Label5
- Caption = "Reorder:"
- Height = 285
- Left = 2820
- TabIndex = 12
- Top = 1860
- Width = 735
- End
- Begin VB.Label Label4
- Caption = "Buffer size (kB) :"
- Height = 285
- Left = 60
- TabIndex = 11
- Top = 1860
- Width = 1395
- End
- Begin VB.Label Label3
- Caption = "Original file:"
- Height = 255
- Left = 60
- TabIndex = 8
- Top = 180
- Width = 1395
- End
- Begin VB.Label Label2
- Caption = "Compressed file:"
- Height = 285
- Left = 60
- TabIndex = 2
- Top = 600
- Width = 1395
- End
- Begin VB.Label Label1
- Caption = "Uncompressed file:"
- Height = 285
- Left = 60
- TabIndex = 1
- Top = 1020
- Width = 1395
- End
- Begin NCTDATACOMPRESSLibCtl.DataCompress DataCompress1
- Left = 1800
- OleObjectBlob = "frmDialog.frx":0000
- Top = 2520
- End
- Attribute VB_Name = "frmDialog"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim T1 As Double
- Dim T2 As Double
- Dim InputDir As String
- Dim OutputDir As String
- Dim byteArray() As Byte
- Private Sub Form_Load()
- InputDir = GetSetting("NCT", "TestNCTDataCompress", "InputDir", "c:\")
- OutputDir = GetSetting("NCT", "TestNCTDataCompress", "OutputDir", "c:\")
- End Sub
- Private Sub Button1_Click()
- Dim sFile As String
- With CommonDialog1
- .FileName = ""
- .InitDir = InputDir
- .DialogTitle = "Open"
- .CancelError = False
- .Filter = "All files (*.*)|*.*"
- .ShowOpen
- If Len(.FileName) = 0 Then Exit Sub
- sFile = .FileName
- End With
- CurDir CommonDialog1.FileName
- InputDir = CurDir
- SaveSetting "NCT", "TestNCTDataCompress", "InputDir", InputDir
- Text1.Text = sFile
- Dim fs As Variant
- Set fs = CreateObject("Scripting.FileSystemObject")
- Text2.Text = fs.GetParentFolderName(sFile) + "\" + fs.GetBaseName(sFile) + ".enc"
- Text3.Text = fs.GetParentFolderName(sFile) + "\" + fs.GetBaseName(sFile) + ".dec"
- End Sub
- Private Sub CompressButton_Click()
- Dim tmpArray(3) As Byte
- Dim inpSize As Long
- Dim outSize As Long
- Dim bufSize As Long
- Dim tmpSize As Long
- Dim curPos As Long
- Dim Ratio As Double
- Dim CRCCode As Long
- If Dir(Text1.Text) = "" Then
- MsgBox "Invalid file name: " & Text1.Text, vbCritical
- Exit Sub
- End If
- ProgressBar1.Value = 0
- bufSize = UpDown1.Value * 1024
- curPos = 0
- outSize = 0
- If Option1.Value = True Then DataCompress1.Algorithm = 1
- If Option2.Value = True Then DataCompress1.Algorithm = 2
- DataCompress1.Reorder = UpDown2.Value
- DataCompress1.PPMMemSize = UpDown3.Value
- DataCompress1.PPMOrder = UpDown4.Value
- T1 = Now
- inpSize = DataCompress1.OpenInputFile(Text1.Text)
- DataCompress1.CreateOutputFile Text2.Text
- tmpArray(0) = DataCompress1.Algorithm
- tmpArray(1) = DataCompress1.Reorder
- tmpArray(2) = DataCompress1.PPMMemSize
- tmpArray(3) = DataCompress1.PPMOrder
- DataCompress1.WriteOutputFile tmpArray()
- outSize = outSize + 4
- Do While curPos < inpSize
- If (inpSize - curPos) < bufSize Then bufSize = inpSize - curPos
-
- byteArray() = DataCompress1.ReadInputFile(curPos, bufSize)
-
- CRCCode = Abs(DataCompress1.GetCRCCodeArray(byteArray()))
-
- byteArray() = DataCompress1.CompressByteArray(byteArray())
- tmpSize = DataCompress1.GetArraySize(byteArray())
-
- WriteLong CRCCode
- WriteLong tmpSize
- DataCompress1.WriteOutputFile byteArray()
-
- curPos = curPos + bufSize
- outSize = outSize + tmpSize + 8
-
- Loop
- DataCompress1.CloseOutputFile
- DataCompress1.CloseInputFile
- T2 = Now
- ProgressBar1.Value = 0
- Ratio = (inpSize - outSize) / inpSize
- MsgBox "Input size: " & inpSize & ". Packed size: " & outSize & ". Compression ratio: " & Format(Ratio, "#0.00%") & ". Time: " & Format((T2 - T1) * 100000, "#0.000") & " sec", vbInformation, "Compression result"
- End Sub
- Private Sub UncompressButton_Click()
- Dim tmpArray() As Byte
- Dim inpSize As Long
- Dim outSize As Long
- Dim tmpSize As Long
- Dim Ratio As Double
- Dim CRCCode As Long
- If Dir(Text2.Text) = "" Or Len(Text2.Text) = 0 Then
- MsgBox "Invalid file name: " & Text2.Text, vbCritical
- Exit Sub
- End If
- ProgressBar1.Value = 0
- curPos = 0
- outSize = 0
- T1 = Now
- inpSize = DataCompress1.OpenInputFile(Text2.Text)
- DataCompress1.CreateOutputFile Text3.Text
- tmpArray() = DataCompress1.ReadInputFile(curPos, 4)
- DataCompress1.Algorithm = tmpArray(0)
- DataCompress1.Reorder = tmpArray(1)
- DataCompress1.PPMMemSize = tmpArray(2)
- DataCompress1.PPMOrder = tmpArray(3)
- curPos = curPos + 4
- Do While curPos < inpSize
- CRCCode = ReadLong(curPos)
- curPos = curPos + 4
- tmpSize = ReadLong(curPos)
- curPos = curPos + 4
-
- byteArray() = DataCompress1.ReadInputFile(curPos, tmpSize)
- curPos = curPos + tmpSize
-
- byteArray() = DataCompress1.DecompressByteArray(byteArray())
-
- If CRCCode <> Abs(DataCompress1.GetCRCCodeArray(byteArray())) Then
- MsgBox "Error input data. Operation canceled!", vbCritical, "Error"
- Exit Do
- End If
-
- outSize = outSize + DataCompress1.GetArraySize(byteArray())
- DataCompress1.WriteOutputFile byteArray()
- Loop
- DataCompress1.CloseOutputFile
- DataCompress1.CloseInputFile
- T2 = Now
- ProgressBar1.Value = 0
- Ratio = (outSize - inpSize) / outSize
- MsgBox "Output size: " & outSize & ". Packed size: " & inpSize & ". Compression ratio: " & Format(Ratio, "#0.00%") & ". Time: " & Format((T2 - T1) * 100000, "#0.000") & " sec", vbInformation, "Compression result"
- End Sub
- Private Sub WriteLong(ByVal L As Long)
- Dim tmpArray(3) As Byte
- Dim i As Long
- For i = 0 To 3
- tmpArray(i) = L Mod 256
- L = (L - L Mod 256) / 256
- Next i
- DataCompress1.WriteOutputFile tmpArray()
- End Sub
- Private Function ReadLong(ByVal curPos As Long) As Long
- Dim tmpArray() As Byte
- tmpArray() = DataCompress1.ReadInputFile(curPos, 4)
- ReadLong = 0
- For i = 3 To 0 Step -1
- ReadLong = ReadLong * 256
- ReadLong = tmpArray(i) + ReadLong
- Next i
- End Function
- Private Sub DataCompress1_CompressBlock(ByVal Percent As Long)
- ProgressBar1.Value = Percent
- End Sub
- Private Sub DataCompress1_DecompressBlock(ByVal Percent As Long)
- ProgressBar1.Value = Percent
- End Sub
-