### Preview Installation with make -n install Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/install.txt Before running 'make install', use 'make -n install' to preview the installation locations. You may need to edit the Makefile for correct man page paths. ```bash make -n install ``` -------------------------------- ### Install with make install Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/install.txt Use 'make install' to install programs and man pages into standard locations after generating a Makefile with the 'configure' script. Requires root privileges. ```bash make install ``` -------------------------------- ### CMake Build with Release Configuration Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Example of configuring a release build with NMake Makefiles and specifying an installation directory. ```bash cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=c:\\libjpeg-turbo {source_directory} nmake install ``` -------------------------------- ### Install libjpeg-turbo with Custom Prefix and Library Directory Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Use 'make install' with specified prefix and libdir to control installation paths for header and library files. ```bash make install prefix=/usr/local libdir=/usr/local/lib64 ``` -------------------------------- ### Windows Installer with NMake Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build the libjpeg-turbo installer package on Windows using NMake. ```batch cd {build_directory} nmake installer ``` -------------------------------- ### Windows Installer with MinGW Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build the libjpeg-turbo installer package on Windows using MinGW. ```bash cd {build_directory} make installer ``` -------------------------------- ### Install IJG Library Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/install.txt To install the IJG library for use in other programs, place the include files and library file in their respective directories. Use 'make install-lib' if a Makefile was generated by 'configure'. ```bash make install-lib ``` -------------------------------- ### Starting JPEG Compression Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/libjpeg.txt Initiate a compression cycle, initializing state and emitting the JPEG header. Use TRUE for a complete interchange datastream. ```c jpeg_start_compress(&cinfo, TRUE); ``` -------------------------------- ### Building NASM from Source RPM Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Instructions for building and installing NASM from a source RPM on older Linux systems where binary RPMs may not work. Ensure texinfo is installed, as NASM build will fail without it. ```bash ARCH=`uname -m` rpmbuild --rebuild nasm-{version}.src.rpm rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm ``` -------------------------------- ### Header File Forward Declaration Example Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/docs/codingstyle.txt Demonstrates preferred practice in header files: use pointers and forward declarations for dependencies instead of direct includes to minimize compile times. ```cpp // Bar.h class Foo; void Bar(Foo *); ``` -------------------------------- ### Example Quantization Table File Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/wizard.txt This file defines two quantization tables (luminance and chrominance) in decimal format, with comments. It can be used with the -qtables switch. ```text # Quantization tables given in JPEG spec, section K.1 # This is table 0 (the luminance table): 16 11 10 16 24 40 51 61 12 12 14 19 26 58 60 55 14 13 16 24 40 57 69 56 14 17 22 29 51 87 80 62 18 22 37 56 68 109 103 77 24 35 55 64 81 104 113 92 49 64 78 87 103 121 120 101 72 92 95 98 112 100 103 99 # This is table 1 (the chrominance table): 17 18 24 47 99 99 99 99 18 21 26 66 99 99 99 99 24 26 56 99 99 99 99 99 47 66 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 ``` -------------------------------- ### Starting Compression Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/libjpeg.txt Call `jpeg_start_compress` to begin the compression process. This initializes internal state, allocates memory, and writes the JPEG datastream header. Once called, no JPEG parameters can be altered until compression is finished. ```APIDOC ## Starting the Compression Cycle ### Description Initiates the JPEG compression process, preparing the library to accept image data. This function writes the initial JPEG header information. ### Function Signature `jpeg_start_compress(struct jpeg_compress_struct *cinfo, boolean write_all_tables)` ### Parameters - `cinfo` (struct jpeg_compress_struct *): Pointer to the compression control structure. - `write_all_tables` (boolean): If TRUE, a complete JPEG datastream with all tables is written. If FALSE, an abbreviated datastream may be used. ### Usage Example ```c /* Assuming cinfo is already set up */ jpeg_start_compress(&cinfo, TRUE); ``` ``` -------------------------------- ### Install JPWL Library Components Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/openjpeg/jpwl/CMakeLists.txt Configures the installation rules for the JPWL library. This specifies where the runtime, library, and archive files should be placed on the system and assigns them to appropriate installation components. ```cmake INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JPWL EXPORT OpenJPEGTargets RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries ) ``` -------------------------------- ### Starting Abbreviated Image Compression Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/libjpeg.txt Pass FALSE as the second parameter to jpeg_start_compress to enable abbreviated image creation. This prevents accidental creation of abbreviated files. ```c jpeg_start_compress(&cinfo, FALSE); ``` -------------------------------- ### 64-bit MinGW Build on Cygwin Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a 64-bit libjpeg-turbo on Cygwin using the MinGW-w64 toolchain. Ensure the necessary mingw64 packages are installed. ```bash cd {build_directory} CC=/usr/bin/x86_64-w64-mingw32-gcc \ cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \ -DCMAKE_AR=/usr/bin/x86_64-w64-mingw32-ar \ -DCMAKE_RANLIB=/usr/bin/x86_64-w64-mingw32-ranlib {source_directory} make ``` -------------------------------- ### 32-bit MinGW Build on Cygwin Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a 32-bit libjpeg-turbo on Cygwin using the MinGW-w64 toolchain. Ensure the necessary mingw64 packages are installed. ```bash cd {build_directory} CC=/usr/bin/i686-w64-mingw32-gcc \ cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \ -DDCMAKE_AR=/usr/bin/i686-w64-mingw32-ar \ -DCMAKE_RANLIB=/usr/bin/i686-w64-mingw32-ranlib {source_directory} make ``` -------------------------------- ### iOS Configure Command Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Example of the configure command for building libjpeg-turbo on iOS, specifying host, build type, and custom compiler/CFLAGS. This command is used to set up the build environment for cross-compilation. ```bash --host arm-apple-darwin10 --enable-static --disable-shared \ CC="$IOS_GCC" LD="$IOS_GCC" \ CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \ LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS" ``` -------------------------------- ### Setting Compression Defaults Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/libjpeg.txt Before starting compression, you must set the input image properties and then call `jpeg_set_defaults` to initialize compression parameters to reasonable values. The `in_color_space` must be set before calling this function. ```APIDOC ## Setting Image Properties and Defaults ### Description Configure the image dimensions, component count, and color space before initializing default compression parameters. ### Function Signature `jpeg_set_defaults(struct jpeg_compress_struct *cinfo)` ### Parameters - `cinfo` (struct jpeg_compress_struct *): Pointer to the compression control structure. - `image_width` (unsigned int): Width of the image in pixels. - `image_height` (unsigned int): Height of the image in pixels. - `input_components` (int): Number of color components per pixel (e.g., 3 for RGB, 1 for grayscale). - `in_color_space` (J_COLOR_SPACE): Colorspace of the input image (e.g., `JCS_RGB`, `JCS_GRAYSCALE`). ### Usage Example ```c struct jpeg_compress_struct cinfo; /* ... setup cinfo ... */ cinfo.image_width = Width; /* image width and height, in pixels */ cinfo.image_height = Height; cinfo.input_components = 3; /* # of color components per pixel */ cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ jpeg_set_defaults(&cinfo); /* Make optional parameter settings here */ ``` ``` -------------------------------- ### Start Output with Target Scan Number in libjpeg-turbo Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/libjpeg.txt Use jpeg_start_output() to begin an output pass. Passing cinfo.input_scan_number as the target scan number ensures that output matches the current input scan, allowing the decoder to adapt its speed to arriving data by skipping output scans as necessary. ```c jpeg_start_output(&cinfo, cinfo.input_scan_number); ``` -------------------------------- ### Successive Approximation Scan Script Example Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/wizard.txt A successive-approximation script equivalent to the default progressive mode for YCbCr images. It progressively sends bits of coefficients, starting with DC and then AC, across multiple scans. ```text # Initial DC scan for Y,Cb,Cr (lowest bit not sent) 0,1,2: 0-0, 0, 1 ; # First AC scan: send first 5 Y AC coefficients, minus 2 lowest bits: 0: 1-5, 0, 2 ; # Send all Cr,Cb AC coefficients, minus lowest bit: # (chroma data is usually too small to be worth subdividing further; # but note we send Cr first since eye is least sensitive to Cb) 2: 1-63, 0, 1 ; 1: 1-63, 0, 1 ; # Send remaining Y AC coefficients, minus 2 lowest bits: 0: 6-63, 0, 2 ; # Send next-to-lowest bit of all Y AC coefficients: 0: 1-63, 2, 1 ; # At this point we've sent all but the lowest bit of all coefficients. # Send lowest bit of DC coefficients 0,1,2: 0-0, 1, 0 ; # Send lowest bit of AC coefficients 2: 1-63, 1, 0 ; 1: 1-63, 1, 0 ; # Y AC lowest bit scan is last; it's usually the largest scan 0: 1-63, 1, 0 ; ``` -------------------------------- ### Configure for 64-bit Library Build on 64-bit Solaris Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Add flags to the configure command to build a 64-bit library on a 64-bit Solaris system. ```bash --host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64 ``` -------------------------------- ### Configure for 32-bit Library Build on 64-bit FreeBSD Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Specify the host, CC, CFLAGS, and LDFLAGS for building a 32-bit library on a 64-bit FreeBSD system. NASM 2.07+ is required. ```bash --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \ LDFLAGS='-B/usr/lib32' ``` -------------------------------- ### Configure for 32-bit Library Build on 64-bit Linux Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Add specific flags to the configure command to build a 32-bit library on a 64-bit Linux system. ```bash --host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32 ``` -------------------------------- ### Basic libjpeg-turbo Build Process Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Standard procedure for building libjpeg-turbo on Linux, FreeBSD, OS X, Cygwin, and Solaris/x86. This generates static and shared libraries. ```bash cd {source_directory} autoreconf -fiv cd {build_directory} sh {source_directory}/configure [additional configure flags] make ``` -------------------------------- ### Configure for 64-bit Build with Oracle Solaris Studio Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a 64-bit version using Oracle Solaris Studio by specifying the host, CC, CFLAGS, and LDFLAGS. ```bash --host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64 ``` -------------------------------- ### Header Guard Naming Convention Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/docs/codingstyle.txt Header guards should match the filename exactly, replacing '.' with '_'. This example assumes a file named 'MyHeader.h'. ```c #define MYHEADER_H ``` -------------------------------- ### Configure for 64-bit Library Build on 64-bit OS X Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Specify the host and NASM path for building a 64-bit library on 64-bit macOS. NASM 2.07 or later is required. ```bash --host x86_64-apple-darwin NASM=/opt/local/bin/nasm ``` -------------------------------- ### Create Debian Package Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a Debian-style binary package for libjpeg-turbo. Requires dpkg. ```bash make deb ``` -------------------------------- ### Sequential JPEG Scan Script Example Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/wizard.txt Defines a partially interleaved sequential JPEG file. The first scan includes only the Y component, and the second scan includes Cb and Cr. ```text 0; # Y only in first scan 1 2; # Cb and Cr in second scan ``` -------------------------------- ### Build Cygwin Package Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a Cygwin binary package for libjpeg-turbo. ```bash make cygwinpkg ``` -------------------------------- ### Aborting and Restarting Display Pass Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/libjpeg.txt If much of the file arrives before a display pass completes, abort the current pass and start a new one with updated information by calling jpeg_finish_output() and then jpeg_start_output(). ```c jpeg_finish_output() and then start a new pass with jpeg_start_output(). ``` -------------------------------- ### Instantiating and Binding UI from HTML in C++ Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/docs/mui-html-fusion.txt Demonstrates C++ code for parsing an HTML fragment, creating a controller, finding specific controls by name, and connecting their events to controller methods. This shows the programmatic interaction with the HTML-defined UI. ```cpp UIFragment *frag = FragmentFromHtml(gUpdateDialogHtml); UpdateAvailableController *controller = new UpdateAvailableController(frag); Button *btnDl = this->frag->FindElement("button", "dl"); btnDl->Connect(controller::OnDownloadPressed); Button *btnNoDl = frag->FindElement("button", "nodl"); btnNoDl->Connect(controller::OnNoDownloadPressed); Controller::OnNoDownloadPressed() { Checkbox *skipCheck = frag->FindElement("checkbox", "skipcheck"); if (skipCheck->IsOn()) { } else { // is off } // close the dialog } RunDialog(frag); ``` -------------------------------- ### Configure for 32-bit Library Build on 64-bit OS X Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Add flags to the configure command to build a 32-bit library on a 64-bit macOS system. ```bash --host i686-apple-darwin CFLAGS='-O3 -m32' LDFLAGS=-m32 ``` -------------------------------- ### Create RPM Package Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a Red Hat-style binary RPM package for libjpeg-turbo. Requires RPM v4 or later. ```bash make rpm ``` -------------------------------- ### Progressive JPEG Scan Script (Spectral Selection) Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/wizard.txt An example of a progressive scan script using only spectral selection. It includes an interleaved DC scan followed by AC scans for Y, Cb, and Cr components. ```text # Interleaved DC scan for Y,Cb,Cr: 0,1,2: 0-0, 0, 0 ; # AC scans: 0: 1-2, 0, 0 ; # First two Y AC coefficients 0: 3-5, 0, 0 ; # Three more 1: 1-63, 0, 0 ; # All AC coefficients for Cb 2: 1-63, 0, 0 ; # All AC coefficients for Cr 0: 6-9, 0, 0 ; # More Y coefficients 0: 10-63, 0, 0 ; # Remaining Y coefficients ``` -------------------------------- ### Start Decompression Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/libjpeg.txt Call jpeg_start_decompress() after setting decompression parameters. This initializes internal state and prepares for data output. For multi-pass modes, this call may take longer. After this call, final output dimensions and colormap info are available. ```c jpeg_start_decompress(&cinfo); ``` -------------------------------- ### Configure libjpeg-turbo for libjpeg v7/v8 API/ABI Emulation Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/README-turbo.txt Build libjpeg-turbo to be a drop-in replacement for libjpeg v7 or v8 by passing specific arguments to the configure script or cmake. ```bash ./configure --with-jpeg7 ``` ```bash ./configure --with-jpeg8 ``` ```bash cmake -DWITH_JPEG7=1 ``` ```bash cmake -DWITH_JPEG8=1 ``` -------------------------------- ### Enabling libjpeg v7 API/ABI Emulation Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Configure option to build a version of libjpeg-turbo compatible with libjpeg v7's API/ABI. ```bash sh {source_directory}/configure --with-jpeg7 [additional configure flags] ``` -------------------------------- ### HTML Dialog Structure with MUI Controls Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/docs/mui-html-fusion.txt Illustrates a declarative HTML structure for a dialog, using custom '' tags to represent MUI components like checkboxes and buttons. This serves as a conceptual example for defining UI elements in HTML. ```html

You have version 5964

New version 5972 is available. Download new version?

&Skip this version

Download &No, thanks

``` -------------------------------- ### Adaptive Decompression Loop in libjpeg-turbo Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/libjpeg.txt This loop structure demonstrates adaptive decompression. It repeatedly consumes input, checks for completion, adjusts parameters, starts output for the current input scan, and finishes the output pass until the entire input is processed. ```c do { absorb any waiting input by calling jpeg_consume_input() final_pass = jpeg_input_complete(&cinfo); adjust output decompression parameters if required jpeg_start_output(&cinfo, cinfo.input_scan_number); ... jpeg_finish_output() } while (! final_pass); ``` -------------------------------- ### Build Solaris Package Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a Solaris package for libjpeg-turbo. Requires pkgmk, pkgtrans, and bzip2. ```bash make sunpkg ``` -------------------------------- ### MinGW-w64 Build on Windows Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a 64-bit libjpeg-turbo on Windows using the native MinGW-w64 toolchain. This is generally faster than the Cygwin version. ```bash cd {build_directory} CC={mingw-w64_binary_path}/x86_64-w64-mingw32-gcc \ cmake -G "MSYS Makefiles" \ -DCMAKE_AR={mingw-w64_binary_path}/x86_64-w64-mingw32-ar \ -DCMAKE_RANLIB={mingw-w64_binary_path}/x86_64-w64-mingw32-ranlib \ ``` -------------------------------- ### Basic MinGW Build Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Use this command to build libjpeg-turbo with MinGW Makefiles. It generates static and shared libraries. ```bash cd {build_directory} cmake -G "MSYS Makefiles" {source_directory} make ``` -------------------------------- ### Enabling libjpeg v8 API/ABI Emulation Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Configure option to build a version of libjpeg-turbo compatible with libjpeg v8's API/ABI. ```bash sh {source_directory}/configure --with-jpeg8 [additional configure flags] ``` -------------------------------- ### Benchmarking cjpeg with libjpeg vs. libjpeg-turbo Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/README-turbo.txt Compares the performance of the cjpeg utility when linked against libjpeg versus libjpeg-turbo. Demonstrates the speed improvement achieved by libjpeg-turbo. ```bash time cjpeg vgl_5674_0098.jpg ``` ```bash export LD_LIBRARY_PATH=/opt/libjpeg-turbo/{lib}:$LD_LIBRARY_PATH time cjpeg vgl_5674_0098.jpg ``` -------------------------------- ### Create Combined Solaris Package Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt On 64-bit Solaris systems, create a package containing both 32-bit and 64-bit libraries. Requires prior 32-bit and 64-bit out-of-tree builds. ```bash make csunpkg [BUILDDIR32={32-bit build directory}] ``` -------------------------------- ### Configure for 64-bit Backward-Compatible Library Build on 64-bit OS X Source: https://github.com/reliak/moonpdf/blob/master/ext/sumatra/ext/libjpeg-turbo/BUILDING.txt Build a 64-bit backward-compatible library on macOS, specifying the host, NASM path, and SDK versions for CFLAGS and LDFLAGS. Requires OS X 10.4 SDK and NASM 2.07+. ```bash --host x86_64-apple-darwin NASM=/opt/local/bin/nasm \ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ -mmacosx-version-min=10.4 -O3' \ LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk \ -mmacosx-version-min=10.4' ```