File indexing completed on 2025-01-19 03:55:55
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 1998-01-25 0007 * Description : helper methods to handle ICC color profile with JPEG file. 0008 * 0009 * SPDX-FileCopyrightText: 1998-2004 by Marti Maria <info at littlecms dot com> 0010 * SPDX-FileCopyrightText: 2005-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 /** 0017 * Notes from Little CMS project (www.littlecms.com) 0018 * 0019 * This file provides code to read and write International Color Consortium 0020 * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has 0021 * defined a standard format for including such data in JPEG "APP2" markers. 0022 * The code given here does not know anything about the internal structure 0023 * of the ICC profile data; it just knows how to put the profile data into 0024 * a JPEG file being written, or get it back out when reading. 0025 * 0026 * This code depends on new features added to the IJG JPEG library as of 0027 * IJG release 6b; it will not compile or work with older IJG versions. 0028 * 0029 * This code would need surgery to work on 16-bit-int machines 0030 * with ICC profiles exceeding 64K bytes in size. See iccjpeg.c 0031 * for details. 0032 */ 0033 0034 #ifndef DIGIKAM_ICC_JPEG_H 0035 #define DIGIKAM_ICC_JPEG_H 0036 0037 #include <stdio.h> /* needed to define "FILE", "NULL" */ 0038 #include <jpeglib.h> 0039 0040 #include "digikam_export.h" 0041 0042 /** 0043 * This routine writes the given ICC profile data into a JPEG file. 0044 * It *must* be called AFTER calling jpeg_start_compress() and BEFORE 0045 * the first call to jpeg_write_scanlines(). 0046 * (This ordering ensures that the APP2 marker(s) will appear after the 0047 * SOI and JFIF or Adobe markers, but before all else.) 0048 */ 0049 DIGIKAM_EXPORT extern void write_icc_profile JPP((j_compress_ptr cinfo, 0050 const JOCTET* icc_data_ptr, 0051 unsigned int icc_data_len)); 0052 0053 /** 0054 * Reading a JPEG file that may contain an ICC profile requires two steps: 0055 * 0056 * 1. After jpeg_create_decompress() but before jpeg_read_header(), 0057 * call setup_read_icc_profile(). This routine tells the IJG library 0058 * to save in memory any APP2 markers it may find in the file. 0059 * 0060 * 2. After jpeg_read_header(), call read_icc_profile() to find out 0061 * whether there was a profile and obtain it if so. 0062 */ 0063 0064 /** 0065 * Prepare for reading an ICC profile 0066 */ 0067 DIGIKAM_EXPORT extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo)); 0068 0069 /** 0070 * See if there was an ICC profile in the JPEG file being read; 0071 * if so, reassemble and return the profile data. 0072 * 0073 * TRUE is returned if an ICC profile was found, FALSE if not. 0074 * If TRUE is returned, *icc_data_ptr is set to point to the 0075 * returned data, and *icc_data_len is set to its length. 0076 * 0077 * IMPORTANT: the data at **icc_data_ptr has been allocated with malloc() 0078 * and must be freed by the caller with free() when the caller no longer 0079 * needs it. (Alternatively, we could write this routine to use the 0080 * IJG library's memory allocator, so that the data would be freed implicitly 0081 * at jpeg_finish_decompress() time. But it seems likely that many apps 0082 * will prefer to have the data stick around after decompression finishes.) 0083 */ 0084 DIGIKAM_EXPORT extern boolean read_icc_profile JPP((j_decompress_ptr cinfo, 0085 JOCTET** icc_data_ptr, 0086 unsigned int* icc_data_len)); 0087 0088 #endif /* DIGIKAM_ICC_JPEG_H */