12/5/2023 0 Comments Jpg compressor![]() ![]() ![]() The license of jpgd.cpp/.h and jpge.cpp/.h is either Public Domain or Apache 2.0. Jpge.exe also includes a few other modes for exhaustive testing of the codec (-x option) and JPEG to TGA decompression (-d option) - see the help text for more info. Where quality_factor ranges from 1-100 (higher is better). Its usage is:īin/jpge source_file.png destination_file.jpg quality_factor The source distribution includes a simple example command line tool called "jpge.exe" (or jpge_圆4.exe for Win64 systems) that converts images from any format that stb_image.c supports (such as PNG, TGA, BMP, etc.) to baseline JPEG using the jpeg_encoder class. It supports progressive and baseline sequential JPEG image files and the H1V1, H2V1, H1V2, and H2V2 chroma subsampling factors. Jpgd supports a superset of JPEG features utilized by jpge, so it can decompress any file generated by jpge along with most (if not almost all) JPEG files you're likely to encounter in the wild. By default, it's enabled (unless it's x86/圆4 gcc and SSE2 is not defined). Set the "JPGD_USE_SSE2" macro to 0 to completely disable SSE2 usage during compilation. Just like the compressor, for more control you can directly utilize the jpgd::jpeg_decompressor class, or call the decompress_jpeg_image_from_stream() function.ĬFlagBoxChromaFiltering: Uses much faster box filtering on the chroma components, but may lead to artifacts on some imagesĬFlagDisableSIMD: Do not use SSE2, even if it's been compiled in Int *actual_comps, int req_comps, uint32_t flags = 0) unsigned char * decompress_jpeg_image_from_file( const char *pSrc_filename, int *width, int *height, Int *width, int *height, int *actual_comps, int req_comps, uint32_t flags = 0) unsigned char * decompress_jpeg_image_from_memory( const unsigned char *pSrc_data, int src_data_size, On return, width/height will be set to the image's dimensions, and actual_comps will be set // to either 1 (grayscale) or 3 (RGB). req_comps can be 1 (grayscale), 3 (RGB), or 4 (RGBA). Loads a JPEG image from a memory buffer. Include jpgd.h and call one of these helper functions in the "jpgd" namespace: You can also call the jpge::jpeg_encoder class directly if you need more control over the image source or how/where the output stream is written. This example uses Sean Barrett's stb_image.c module to load image files. bool compress_image_to_jpeg_file_in_memory( void *pBuf, int &buf_size, int width, int height, int num_channels, ![]() If return value is true, buf_size will be set to the size of the compressed data. ![]() On entry, buf_size is the size of the output buffer pointed at by pBuf, which should be at least ~1024 bytes. bool compress_image_to_jpeg_file( const char *pFilename, int width, int height, int num_channels,Ĭonst uint8 *pImage_data, const params &comp_params = params()) num_channels must be 1 (Y), 3 (RGB), or 4 (RGBA), image pitch must be width*num_channels. Include jpge.h and call one of these helper functions in the "jpge" namespace: Thanks to Alex Evans for adding several features to jpge (see a smaller jpg encoder). The source distribution includes a sample VS2019 Win32/圆4 solution and CMakeLists.txt file for compilation with gcc/clang. This property makes the decompressor useful on small 32-bit microcontrollers. Also unlike many other small JPEG decompressors, jpgd.cpp does not require loading the entire image into memory, just single MCU rows at a time (even when doing linear chroma upsampling). Unlike every other small JPEG decompressor I've seen, this decompressor has been fuzz tested using zzuf and afl, making it resilent against crashing, overwriting memory, or bad memory reads when given accidently or purposely corrupted inputs. It supports both box and linear chroma upsampling, and grayscale or H1V1/H2V1/H1V2/H2V2 chroma upsampling factors. The source distribution also includes an optional, completely stand-alone public domain (or Apache 2.0) JPEG decompression class with progressive image support in a single source file jpgd.cpp. The current release supports both single pass Huffman coding and more efficient (but slower) two pass coding, makes only a single dynamic memory allocation, and now accepts 32-bit source images. The core compression class consists of a single 890 line C++ file with a small header, along with a couple optional higher-level helper/example functions. It supports grayscale and H1V1/H2V1/H2V2 chroma subsampling factors, Libjpeg-compatible quality settings, and is reasonably fast with fairly low (typically less than 64KB) memory consumption. A small (~1000 lines), easy to use public domain (or Apache 2.0) C++ class in a single source file jpge.cpp that writes baseline JPEG compressed images. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |