Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Compress BytesDemonstrates how to compress binary data.
#include <C_CkFileAccessW.h> #include <C_CkByteData.h> #include <C_CkCompressionW.h> void ChilkatSample(void) { HCkFileAccessW fac; HCkByteData fileBytes; HCkCompressionW compress; HCkByteData compressedBytes; BOOL success; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. fac = CkFileAccessW_Create(); fileBytes = CkByteData_Create(); success = CkFileAccessW_ReadEntireFile(fac,L"qa_data/bmp/big.bmp",fileBytes); if (CkFileAccessW_getLastMethodSuccess(fac) != TRUE) { wprintf(L"%s\n",CkFileAccessW_lastErrorText(fac)); CkFileAccessW_Dispose(fac); CkByteData_Dispose(fileBytes); return; } compress = CkCompressionW_Create(); CkCompressionW_putAlgorithm(compress,L"deflate"); compressedBytes = CkByteData_Create(); success = CkCompressionW_CompressBytes(compress,fileBytes,compressedBytes); if (CkCompressionW_getLastMethodSuccess(compress) != TRUE) { wprintf(L"%s\n",CkCompressionW_lastErrorText(compress)); CkFileAccessW_Dispose(fac); CkByteData_Dispose(fileBytes); CkCompressionW_Dispose(compress); CkByteData_Dispose(compressedBytes); return; } success = CkFileAccessW_WriteEntireFile(fac,L"qa_output/compressedBmp.dat",compressedBytes); if (CkFileAccessW_getLastMethodSuccess(fac) != TRUE) { wprintf(L"%s\n",CkFileAccessW_lastErrorText(fac)); CkFileAccessW_Dispose(fac); CkByteData_Dispose(fileBytes); CkCompressionW_Dispose(compress); CkByteData_Dispose(compressedBytes); return; } CkFileAccessW_Dispose(fac); CkByteData_Dispose(fileBytes); CkCompressionW_Dispose(compress); CkByteData_Dispose(compressedBytes); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.