michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * iccprofile.h michael@0: * michael@0: * This file provides code to read and write International Color Consortium michael@0: * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has michael@0: * defined a standard format for including such data in JPEG "APP2" markers. michael@0: * The code given here does not know anything about the internal structure michael@0: * of the ICC profile data; it just knows how to put the profile data into michael@0: * a JPEG file being written, or get it back out when reading. michael@0: * michael@0: * This code depends on new features added to the IJG JPEG library as of michael@0: * IJG release 6b; it will not compile or work with older IJG versions. michael@0: * michael@0: * NOTE: this code would need surgery to work on 16-bit-int machines michael@0: * with ICC profiles exceeding 64K bytes in size. See iccprofile.c michael@0: * for details. michael@0: */ michael@0: michael@0: #include /* needed to define "FILE", "NULL" */ michael@0: #include "jpeglib.h" michael@0: michael@0: /* michael@0: * Reading a JPEG file that may contain an ICC profile requires two steps: michael@0: * michael@0: * 1. After jpeg_create_decompress() but before jpeg_read_header(), michael@0: * call setup_read_icc_profile(). This routine tells the IJG library michael@0: * to save in memory any APP2 markers it may find in the file. michael@0: * michael@0: * 2. After jpeg_read_header(), call read_icc_profile() to find out michael@0: * whether there was a profile and obtain it if so. michael@0: */ michael@0: michael@0: michael@0: /* michael@0: * Prepare for reading an ICC profile michael@0: */ michael@0: michael@0: extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo)); michael@0: michael@0: michael@0: /* michael@0: * See if there was an ICC profile in the JPEG file being read; michael@0: * if so, reassemble and return the profile data. michael@0: * michael@0: * TRUE is returned if an ICC profile was found, FALSE if not. michael@0: * If TRUE is returned, *icc_data_ptr is set to point to the michael@0: * returned data, and *icc_data_len is set to its length. michael@0: * michael@0: * IMPORTANT: the data at **icc_data_ptr has been allocated with malloc() michael@0: * and must be freed by the caller with free() when the caller no longer michael@0: * needs it. (Alternatively, we could write this routine to use the michael@0: * IJG library's memory allocator, so that the data would be freed implicitly michael@0: * at jpeg_finish_decompress() time. But it seems likely that many apps michael@0: * will prefer to have the data stick around after decompression finishes.) michael@0: */ michael@0: michael@0: extern boolean read_icc_profile JPP((j_decompress_ptr cinfo, michael@0: JOCTET **icc_data_ptr, michael@0: unsigned int *icc_data_len));