/* * jcicc.c * * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman. * Copyright (C) 2017, D. R. Commander. * For conditions of distribution and use, see the accompanying README.ijg * file. * * This file provides code to write International Color Consortium (ICC) device * profiles embedded in JFIF JPEG image files. The ICC has defined a standard * for including such data in JPEG "APP2" markers. The code given here does * not know anything about the internal structure of the ICC profile data; it * just knows how to embed the profile data in a JPEG file while writing it. */ #define JPEG_INTERNALS #include "jinclude.h" #include "jpeglib.h" #include "jerror.h" /* * Since an ICC profile can be larger than the maximum size of a JPEG marker * (64K), we need provisions to split it into multiple markers. The format * defined by the ICC specifies one or more APP2 markers containing the * following data: * Identifying string ASCII "ICC_PROFILE\0" (12 bytes) * Marker sequence number 1 for first APP2, 2 for next, etc (1 byte) * Number of markers Total number of APP2's used (1 byte) * Profile data (remainder of APP2 data) * Decoders should use the marker sequence numbers to reassemble the profile, * rather than assuming that the APP2 markers appear in the correct sequence. */ #define ICC_MARKER … #define ICC_OVERHEAD_LEN … #define MAX_BYTES_IN_MARKER … #define MAX_DATA_BYTES_IN_MARKER … /* * This routine writes the given ICC profile data into a JPEG file. It *must* * be called AFTER calling jpeg_start_compress() and BEFORE the first call to * jpeg_write_scanlines(). (This ordering ensures that the APP2 marker(s) will * appear after the SOI and JFIF or Adobe markers, but before all else.) */ GLOBAL(void) jpeg_write_icc_profile(j_compress_ptr cinfo, const JOCTET *icc_data_ptr, unsigned int icc_data_len) { … }