11 #include <type_traits>
81 this->type = Type::Int32;
90 this->type = Type::Uint32;
91 this->uint32Value = v;
99 this->type = Type::Boolean;
113 this->ThrowIfTypeIsUnequalTo(Type::Int32);
114 return this->int32Value;
122 this->ThrowIfTypeIsUnequalTo(Type::Uint32);
123 return this->uint32Value;
131 this->ThrowIfTypeIsUnequalTo(Type::Boolean);
132 return this->boolValue;
139 std::int32_t int32Value;
140 std::uint32_t uint32Value;
144 void ThrowIfTypeIsUnequalTo(Type typeToCheck)
const
146 if (this->type != typeToCheck)
148 throw std::runtime_error(
"Unexpected type encountered.");
177 return this->TryGetProperty(
static_cast<typename std::underlying_type<libCZI::CompressionParameterKey>::type
>(key), parameter);
256 std::uint32_t sourceWidth,
257 std::uint32_t sourceHeight,
258 std::uint32_t sourceStride,
261 const std::function<
void* (
size_t)>& allocateTempBuffer,
262 const std::function<
void(
void*)>& freeTempBuffer,
264 size_t& sizeDestination,
291 std::uint32_t sourceWidth,
292 std::uint32_t sourceHeight,
293 std::uint32_t sourceStride,
296 const std::function<
void* (
size_t)>& allocateTempBuffer,
297 const std::function<
void(
void*)>& freeTempBuffer,
327 std::uint32_t sourceWidth,
328 std::uint32_t sourceHeight,
329 std::uint32_t sourceStride,
333 size_t& sizeDestination,
360 std::uint32_t sourceWidth,
361 std::uint32_t sourceHeight,
362 std::uint32_t sourceStride,
412 std::uint32_t sourceWidth,
413 std::uint32_t sourceHeight,
414 std::uint32_t sourceStride,
417 const std::function<
void* (
size_t)>& allocateTempBuffer,
418 const std::function<
void(
void*)>& freeTempBuffer,
420 size_t& sizeDestination,
452 std::uint32_t sourceWidth,
453 std::uint32_t sourceHeight,
454 std::uint32_t sourceStride,
457 const std::function<
void* (
size_t)>& allocateTempBuffer,
458 const std::function<
void(
void*)>& freeTempBuffer,
487 std::uint32_t sourceWidth,
488 std::uint32_t sourceHeight,
489 std::uint32_t sourceStride,
493 size_t& sizeDestination,
518 std::uint32_t sourceWidth,
519 std::uint32_t sourceHeight,
520 std::uint32_t sourceStride,
548 std::uint32_t height,
549 std::uint32_t stride,
560 std::map<int, CompressParameter>
map;
570 const auto it = this->map.find(key);
571 if (it != this->map.cend())
573 if (parameter !=
nullptr)
575 *parameter = it->second;
Definition: libCZI_compress.h:558
bool TryGetProperty(int key, CompressParameter *parameter) const override
Definition: libCZI_compress.h:568
std::map< int, CompressParameter > map
The key-value map containing "compression parameters".
Definition: libCZI_compress.h:560
Definition: libCZI_compress.h:156
bool TryGetProperty(libCZI::CompressionParameterKey key, CompressParameter *parameter) const
Definition: libCZI_compress.h:175
virtual bool TryGetProperty(int key, CompressParameter *parameter) const =0
Interface representing a "block of memory". It is used to hold the result of a compression-operation.
Definition: libCZI_compress.h:183
virtual void * GetPtr()=0
virtual size_t GetSizeOfData() const =0
Definition: libCZI_compress.h:531
static std::shared_ptr< IMemoryBlock > Compress(libCZI::PixelType pixel_type, std::uint32_t width, std::uint32_t height, std::uint32_t stride, const void *ptrData, const ICompressParameters *parameters)
Definition: libCZI_compress.h:208
static bool CompressZStd1(std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const std::function< void *(size_t)> &allocateTempBuffer, const std::function< void(void *)> &freeTempBuffer, void *destination, size_t &sizeDestination, const ICompressParameters *parameters)
static bool CompressZStd1(std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, void *destination, size_t &sizeDestination, const ICompressParameters *parameters)
static size_t CalculateMaxCompressedSizeZStd1(std::uint32_t sourceWidth, std::uint32_t sourceHeight, libCZI::PixelType sourcePixeltype)
static bool CompressZStd0(std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, void *destination, size_t &sizeDestination, const ICompressParameters *parameters)
static std::shared_ptr< IMemoryBlock > CompressZStd1Alloc(std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const ICompressParameters *parameters)
static std::shared_ptr< IMemoryBlock > CompressZStd1Alloc(std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const std::function< void *(size_t)> &allocateTempBuffer, const std::function< void(void *)> &freeTempBuffer, const ICompressParameters *parameters)
static std::shared_ptr< IMemoryBlock > CompressZStd0Alloc(std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const ICompressParameters *parameters)
static size_t CalculateMaxCompressedSizeZStd0(std::uint32_t sourceWidth, std::uint32_t sourceHeight, libCZI::PixelType sourcePixeltype)
static std::shared_ptr< IMemoryBlock > CompressZStd0Alloc(std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const std::function< void *(size_t)> &allocateTempBuffer, const std::function< void(void *)> &freeTempBuffer, const ICompressParameters *parameters)
static bool CompressZStd0(std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const std::function< void *(size_t)> &allocateTempBuffer, const std::function< void(void *)> &freeTempBuffer, void *destination, size_t &sizeDestination, const ICompressParameters *parameters)
External interfaces, classes, functions and structs are found in the namespace "libCZI".
Definition: libCZI.h:31
CompressionParameterKey
Definition: libCZI_compress.h:20
@ ZSTD_RAWCOMPRESSIONLEVEL
@ ZSTD_PREPROCESS_DOLOHIBYTEPACKING
PixelType
An enum representing a pixel-type.
Definition: libCZI_Pixels.h:114
@ Invalid
Invalid pixel type.
Simple variant type used for the compression-parameters-property-bag.
Definition: libCZI_compress.h:37
CompressParameter(std::int32_t v)
Definition: libCZI_compress.h:55
CompressParameter()
Default constructor - setting the variant to 'invalid'.
Definition: libCZI_compress.h:48
void SetUInt32(std::uint32_t v)
Definition: libCZI_compress.h:88
Type GetType() const
Definition: libCZI_compress.h:106
std::int32_t GetInt32() const
Definition: libCZI_compress.h:111
std::uint32_t GetUInt32() const
Definition: libCZI_compress.h:120
void SetInt32(std::int32_t v)
Definition: libCZI_compress.h:79
CompressParameter(bool v)
Definition: libCZI_compress.h:71
Type
Values that represent the type represented by this variant.
Definition: libCZI_compress.h:40
CompressParameter(std::uint32_t v)
Definition: libCZI_compress.h:63
bool GetBoolean() const
Definition: libCZI_compress.h:129
void SetBoolean(bool v)
Definition: libCZI_compress.h:97