File indexing completed on 2024-05-12 04:19:35

0001 /*
0002  * Little cms
0003  * Copyright (C) 1998-2004 Marti Maria <x@uknown.com>
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining
0006  * a copy of this software and associated documentation files (the
0007  * "Software"), to deal in the Software without restriction, including
0008  * without limitation the rights to use, copy, modify, merge, publish,
0009  * distribute, sublicense, and/or sell copies of the Software, and to
0010  * permit persons to whom the Software is furnished to do so, subject to
0011  * the following conditions:
0012  *
0013  * The above copyright notice and this permission notice shall be included
0014  * in all copies or substantial portions of the Software.
0015  *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
0017  * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
0018  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0019  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
0020  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0021  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0022  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0023  *
0024  * iccprofile.h
0025  *
0026  * This file provides code to read and write International Color Consortium
0027  * (ICC) device profiles embedded in JFIF JPEG image files.  The ICC has
0028  * defined a standard format for including such data in JPEG "APP2" markers.
0029  * The code given here does not know anything about the internal structure
0030  * of the ICC profile data; it just knows how to put the profile data into
0031  * a JPEG file being written, or get it back out when reading.
0032  *
0033  * This code depends on new features added to the IJG JPEG library as of
0034  * IJG release 6b; it will not compile or work with older IJG versions.
0035  *
0036  * NOTE: this code would need surgery to work on 16-bit-int machines
0037  * with ICC profiles exceeding 64K bytes in size.  See iccprofile.c
0038  * for details.
0039  */
0040 #ifndef ICCJPEG
0041 #define ICCJPEG
0042 
0043 #include <stdio.h>      /* needed to define "FILE", "NULL" */
0044 #include "jpeglib.h"
0045 
0046 
0047 /*
0048  * This routine writes the given ICC profile data into a JPEG file.
0049  * It *must* be called AFTER calling jpeg_start_compress() and BEFORE
0050  * the first call to jpeg_write_scanlines().
0051  * (This ordering ensures that the APP2 marker(s) will appear after the
0052  * SOI and JFIF or Adobe markers, but before all else.)
0053  */
0054 
0055 extern void write_icc_profile JPP((j_compress_ptr cinfo,
0056                                    const JOCTET *icc_data_ptr,
0057                                    unsigned int icc_data_len));
0058 
0059 
0060 /*
0061  * Reading a JPEG file that may contain an ICC profile requires two steps:
0062  *
0063  * 1. After jpeg_create_decompress() but before jpeg_read_header(),
0064  *    call setup_read_icc_profile().  This routine tells the IJG library
0065  *    to save in memory any APP2 markers it may find in the file.
0066  *
0067  * 2. After jpeg_read_header(), call read_icc_profile() to find out
0068  *    whether there was a profile and obtain it if so.
0069  */
0070 
0071 
0072 /*
0073  * Prepare for reading an ICC profile
0074  */
0075 
0076 extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo));
0077 
0078 
0079 /*
0080  * See if there was an ICC profile in the JPEG file being read;
0081  * if so, reassemble and return the profile data.
0082  *
0083  * true is returned if an ICC profile was found, false if not.
0084  * If true is returned, *icc_data_ptr is set to point to the
0085  * returned data, and *icc_data_len is set to its length.
0086  *
0087  * IMPORTANT: the data at **icc_data_ptr has been allocated with malloc()
0088  * and must be freed by the caller with free() when the caller no longer
0089  * needs it.  (Alternatively, we could write this routine to use the
0090  * IJG library's memory allocator, so that the data would be freed implicitly
0091  * at jpeg_finish_decompress() time.  But it seems likely that many apps
0092  * will prefer to have the data stick around after decompression finishes.)
0093  */
0094 
0095 extern boolean read_icc_profile JPP((j_decompress_ptr cinfo,
0096                                      JOCTET **icc_data_ptr,
0097                                      unsigned int *icc_data_len));
0098 
0099 #endif