(VB.NET) Compress Bytes
Demonstrates how to compress binary data.
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim fac As New Chilkat.FileAccess
Dim fileBytes() As Byte
fileBytes = fac.ReadEntireFile("qa_data/bmp/big.bmp")
If (fac.LastMethodSuccess <> True) Then
Debug.WriteLine(fac.LastErrorText)
Exit Sub
End If
Dim compress As New Chilkat.Compression
compress.Algorithm = "deflate"
Dim compressedBytes() As Byte
compressedBytes = compress.CompressBytes(fileBytes)
If (compress.LastMethodSuccess <> True) Then
Debug.WriteLine(compress.LastErrorText)
Exit Sub
End If
Dim success As Boolean = fac.WriteEntireFile("qa_output/compressedBmp.dat",compressedBytes)
If (fac.LastMethodSuccess <> True) Then
Debug.WriteLine(fac.LastErrorText)
Exit Sub
End If
|