filters
iccjpeg.h
00001 /* 00002 * Little cms 00003 * Copyright (C) 1998-2004 Marti Maria 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining 00006 * a copy of this software and associated documentation files (the 00007 * "Software"), to deal in the Software without restriction, including 00008 * without limitation the rights to use, copy, modify, merge, publish, 00009 * distribute, sublicense, and/or sell copies of the Software, and to 00010 * permit persons to whom the Software is furnished to do so, subject to 00011 * the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 00017 * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 00018 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00020 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00021 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00022 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * iccprofile.h 00025 * 00026 * This file provides code to read and write International Color Consortium 00027 * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has 00028 * defined a standard format for including such data in JPEG "APP2" markers. 00029 * The code given here does not know anything about the internal structure 00030 * of the ICC profile data; it just knows how to put the profile data into 00031 * a JPEG file being written, or get it back out when reading. 00032 * 00033 * This code depends on new features added to the IJG JPEG library as of 00034 * IJG release 6b; it will not compile or work with older IJG versions. 00035 * 00036 * NOTE: this code would need surgery to work on 16-bit-int machines 00037 * with ICC profiles exceeding 64K bytes in size. See iccprofile.c 00038 * for details. 00039 */ 00040 #ifndef ICCJPEG 00041 #define ICCJPEG 00042 00043 #include <stdio.h> /* needed to define "FILE", "NULL" */ 00044 #include "jpeglib.h" 00045 00046 00047 /* 00048 * This routine writes the given ICC profile data into a JPEG file. 00049 * It *must* be called AFTER calling jpeg_start_compress() and BEFORE 00050 * the first call to jpeg_write_scanlines(). 00051 * (This ordering ensures that the APP2 marker(s) will appear after the 00052 * SOI and JFIF or Adobe markers, but before all else.) 00053 */ 00054 00055 extern void write_icc_profile JPP((j_compress_ptr cinfo, 00056 const JOCTET *icc_data_ptr, 00057 unsigned int icc_data_len)); 00058 00059 00060 /* 00061 * Reading a JPEG file that may contain an ICC profile requires two steps: 00062 * 00063 * 1. After jpeg_create_decompress() but before jpeg_read_header(), 00064 * call setup_read_icc_profile(). This routine tells the IJG library 00065 * to save in memory any APP2 markers it may find in the file. 00066 * 00067 * 2. After jpeg_read_header(), call read_icc_profile() to find out 00068 * whether there was a profile and obtain it if so. 00069 */ 00070 00071 00072 /* 00073 * Prepare for reading an ICC profile 00074 */ 00075 00076 extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo)); 00077 00078 00079 /* 00080 * See if there was an ICC profile in the JPEG file being read; 00081 * if so, reassemble and return the profile data. 00082 * 00083 * TRUE is returned if an ICC profile was found, FALSE if not. 00084 * If TRUE is returned, *icc_data_ptr is set to point to the 00085 * returned data, and *icc_data_len is set to its length. 00086 * 00087 * IMPORTANT: the data at **icc_data_ptr has been allocated with malloc() 00088 * and must be freed by the caller with free() when the caller no longer 00089 * needs it. (Alternatively, we could write this routine to use the 00090 * IJG library's memory allocator, so that the data would be freed implicitly 00091 * at jpeg_finish_decompress() time. But it seems likely that many apps 00092 * will prefer to have the data stick around after decompression finishes.) 00093 */ 00094 00095 extern boolean read_icc_profile JPP((j_decompress_ptr cinfo, 00096 JOCTET **icc_data_ptr, 00097 unsigned int *icc_data_len)); 00098 00099 #endif