(C#) 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.
Chilkat.FileAccess fac = new Chilkat.FileAccess();
byte[] fileBytes = null;
fileBytes = fac.ReadEntireFile("qa_data/bmp/big.bmp");
if (fac.LastMethodSuccess != true) {
Debug.WriteLine(fac.LastErrorText);
return;
}
Chilkat.Compression compress = new Chilkat.Compression();
compress.Algorithm = "deflate";
byte[] compressedBytes = null;
compressedBytes = compress.CompressBytes(fileBytes);
if (compress.LastMethodSuccess != true) {
Debug.WriteLine(compress.LastErrorText);
return;
}
bool success = fac.WriteEntireFile("qa_output/compressedBmp.dat",compressedBytes);
if (fac.LastMethodSuccess != true) {
Debug.WriteLine(fac.LastErrorText);
return;
}
|