iccjpeg.h (2652B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 /* 6 * iccjpeg.h 7 * 8 * This file provides code to read and write International Color Consortium 9 * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has 10 * defined a standard format for including such data in JPEG "APP2" markers. 11 * The code given here does not know anything about the internal structure 12 * of the ICC profile data; it just knows how to put the profile data into 13 * a JPEG file being written, or get it back out when reading. 14 * 15 * This code depends on new features added to the IJG JPEG library as of 16 * IJG release 6b; it will not compile or work with older IJG versions. 17 * 18 * NOTE: this code would need surgery to work on 16-bit-int machines 19 * with ICC profiles exceeding 64K bytes in size. See iccprofile.c 20 * for details. 21 */ 22 23 #ifndef mozilla_image_decoders_iccjpeg_h 24 #define mozilla_image_decoders_iccjpeg_h 25 26 #include <stdio.h> /* needed to define "FILE", "NULL" */ 27 #include "jpeglib.h" 28 29 /* 30 * Reading a JPEG file that may contain an ICC profile requires two steps: 31 * 32 * 1. After jpeg_create_decompress() but before jpeg_read_header(), 33 * call setup_read_icc_profile(). This routine tells the IJG library 34 * to save in memory any APP2 markers it may find in the file. 35 * 36 * 2. After jpeg_read_header(), call read_icc_profile() to find out 37 * whether there was a profile and obtain it if so. 38 */ 39 40 /* 41 * Prepare for reading an ICC profile 42 */ 43 44 extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo)); 45 46 /* 47 * See if there was an ICC profile in the JPEG file being read; 48 * if so, reassemble and return the profile data. 49 * 50 * TRUE is returned if an ICC profile was found, FALSE if not. 51 * If TRUE is returned, *icc_data_ptr is set to point to the 52 * returned data, and *icc_data_len is set to its length. 53 * 54 * IMPORTANT: the data at **icc_data_ptr has been allocated with malloc() 55 * and must be freed by the caller with free() when the caller no longer 56 * needs it. (Alternatively, we could write this routine to use the 57 * IJG library's memory allocator, so that the data would be freed implicitly 58 * at jpeg_finish_decompress() time. But it seems likely that many apps 59 * will prefer to have the data stick around after decompression finishes.) 60 */ 61 62 extern boolean read_icc_profile JPP((j_decompress_ptr cinfo, 63 JOCTET** icc_data_ptr, 64 unsigned int* icc_data_len)); 65 #endif // mozilla_image_decoders_iccjpeg_h