Class JpgCompress#
Defined in File libCZI_compress.h
Class Documentation#
-
class JpgCompress#
Compresses an 8-bit grayscale or BGR bitmap into a JPEG bitstream.
Public Static Functions
-
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 = nullptr)#
Compress a Gray8 or Bgr24 bitmap for a subblock with CompressionMode::Jpg. For Bgr24, reducing chroma resolution can shrink the bitstream at the cost of fine color detail.
- Parameters:
pixel_type – The source pixel type, Gray8 or Bgr24.
width – Source width in pixels.
height – Source height in pixels.
stride – Distance in bytes between successive source rows.
ptrData – Pointer to the first row. The buffer must contain all source pixels.
parameters – Optional property bag. JPG_QUALITY defaults to 90, JPG_SUBSAMP to 4:4:4, and JPG_OPTIMIZE to false. Missing or incorrectly typed properties use their defaults.
- Throws:
std::invalid_argument – For unsupported pixel types, invalid source arguments, or an invalid Bgr24 subsampling value.
std::runtime_error – If TurboJPEG cannot encode the bitmap.
- Returns:
A memory block owning the compressed JPEG bitstream.
-
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 = nullptr)#