From 5a422aba704c375a307a902bafe658342e209906 Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 17 Oct 2008 06:10:15 +0000 Subject: First commit - moving from LuaForge to SourceForge --- src/im_compress.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/im_compress.cpp (limited to 'src/im_compress.cpp') diff --git a/src/im_compress.cpp b/src/im_compress.cpp new file mode 100644 index 0000000..8a9a863 --- /dev/null +++ b/src/im_compress.cpp @@ -0,0 +1,44 @@ +/** \file + * \brief Data Compression Utilities + * + * See Copyright Notice in im_lib.h + * $Id: im_compress.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + */ + + +#include + +#include "im_util.h" +#include "zlib.h" + +extern "C" { +#include "lzf.h" +} + +int imCompressDataZ(const void* src_data, int src_size, void* dst_data, int dst_size, int zip_quality) +{ + uLongf ret_size = (uLongf)dst_size; + if (compress2((Bytef*)dst_data, &ret_size, (const Bytef*)src_data, src_size, zip_quality) != Z_OK) + return 0; + + return (int)ret_size; +} + +int imCompressDataUnZ(const void* src_data, int src_size, void* dst_data, int dst_size) +{ + uLongf ret_size = (uLongf)dst_size; + if (uncompress((Bytef*)dst_data, &ret_size, (const Bytef*)src_data, src_size) != Z_OK) + return 0; + + return (int)ret_size; +} + +int imCompressDataLZF(const void* src_data, int src_size, void* dst_data, int dst_size) +{ + return lzf_compress(src_data, src_size, dst_data, dst_size); +} + +int imCompressDataUnLZF(const void* src_data, int src_size, void* dst_data, int dst_size) +{ + return lzf_decompress(src_data, src_size, dst_data, dst_size); +} -- cgit v1.2.3