| 1 |
/* |
| 2 |
* Little cms |
| 3 |
* Copyright (C) 1998-2004 Marti Maria <[email protected]> |
| 4 |
* |
| 5 |
* Permission is hereby granted, free of charge, to any person obtaining |
| 6 |
* a copy of this software and associated documentation files (the |
| 7 |
* "Software"), to deal in the Software without restriction, including |
| 8 |
* without limitation the rights to use, copy, modify, merge, publish, |
| 9 |
* distribute, sublicense, and/or sell copies of the Software, and to |
| 10 |
* permit persons to whom the Software is furnished to do so, subject to |
| 11 |
* the following conditions: |
| 12 |
* |
| 13 |
* The above copyright notice and this permission notice shall be included |
| 14 |
* in all copies or substantial portions of the Software. |
| 15 |
* |
| 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY |
| 17 |
* KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
| 18 |
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 20 |
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 21 |
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 22 |
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 |
* |
| 24 |
* iccprofile.h |
| 25 |
* |
| 26 |
* This file provides code to read and write International Color Consortium |
| 27 |
* (ICC) device profiles embedded in JFIF JPEG image files. The ICC has |
| 28 |
* defined a standard format for including such data in JPEG "APP2" markers. |
| 29 |
* The code given here does not know anything about the internal structure |
| 30 |
* of the ICC profile data; it just knows how to put the profile data into |
| 31 |
* a JPEG file being written, or get it back out when reading. |
| 32 |
* |
| 33 |
* This code depends on new features added to the IJG JPEG library as of |
| 34 |
* IJG release 6b; it will not compile or work with older IJG versions. |
| 35 |
* |
| 36 |
* NOTE: this code would need surgery to work on 16-bit-int machines |
| 37 |
* with ICC profiles exceeding 64K bytes in size. See iccprofile.c |
| 38 |
* for details. |
| 39 |
*/ |
| 40 |
#ifndef ICCJPEG |
| 41 |
#define ICCJPEG |
| 42 |
|
| 43 |
#include <stdio.h> /* needed to define "FILE", "0" */ |
| 44 |
#include "jpeglib.h" |
| 45 |
|
| 46 |
|
| 47 |
/* |
| 48 |
* This routine writes the given ICC profile data into a JPEG file. |
| 49 |
* It *must* be called AFTER calling jpeg_start_compress() and BEFORE |
| 50 |
* the first call to jpeg_write_scanlines(). |
| 51 |
* (This ordering ensures that the APP2 marker(s) will appear after the |
| 52 |
* SOI and JFIF or Adobe markers, but before all else.) |
| 53 |
*/ |
| 54 |
|
| 55 |
extern void write_icc_profile JPP((j_compress_ptr cinfo, |
| 56 |
const JOCTET *icc_data_ptr, |
| 57 |
unsigned int icc_data_len)); |
| 58 |
|
| 59 |
|
| 60 |
/* |
| 61 |
* Reading a JPEG file that may contain an ICC profile requires two steps: |
| 62 |
* |
| 63 |
* 1. After jpeg_create_decompress() but before jpeg_read_header(), |
| 64 |
* call setup_read_icc_profile(). This routine tells the IJG library |
| 65 |
* to save in memory any APP2 markers it may find in the file. |
| 66 |
* |
| 67 |
* 2. After jpeg_read_header(), call read_icc_profile() to find out |
| 68 |
* whether there was a profile and obtain it if so. |
| 69 |
*/ |
| 70 |
|
| 71 |
|
| 72 |
/* |
| 73 |
* Prepare for reading an ICC profile |
| 74 |
*/ |
| 75 |
|
| 76 |
extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo)); |
| 77 |
|
| 78 |
|
| 79 |
/* |
| 80 |
* See if there was an ICC profile in the JPEG file being read; |
| 81 |
* if so, reassemble and return the profile data. |
| 82 |
* |
| 83 |
* true is returned if an ICC profile was found, false if not. |
| 84 |
* If true is returned, *icc_data_ptr is set to point to the |
| 85 |
* returned data, and *icc_data_len is set to its length. |
| 86 |
* |
| 87 |
* IMPORTANT: the data at **icc_data_ptr has been allocated with malloc() |
| 88 |
* and must be freed by the caller with free() when the caller no longer |
| 89 |
* needs it. (Alternatively, we could write this routine to use the |
| 90 |
* IJG library's memory allocator, so that the data would be freed implicitly |
| 91 |
* at jpeg_finish_decompress() time. But it seems likely that many apps |
| 92 |
* will prefer to have the data stick around after decompression finishes.) |
| 93 |
*/ |
| 94 |
|
| 95 |
extern boolean read_icc_profile JPP((j_decompress_ptr cinfo, |
| 96 |
JOCTET **icc_data_ptr, |
| 97 |
unsigned int *icc_data_len)); |
| 98 |
|
| 99 |
#endif |