/* * jdicc.c * * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman. * Copyright (C) 2017, D. R. Commander. * For conditions of distribution and use, see the accompanying README.ijg * file. * * This file provides code to read International Color Consortium (ICC) device * profiles embedded in JFIF JPEG image files. The ICC has defined a standard * for including such data in JPEG "APP2" markers. The code given here does * not know anything about the internal structure of the ICC profile data; it * just knows how to get the profile data from a JPEG file while reading it. */ #define JPEG_INTERNALS #include "jinclude.h" #include "jpeglib.h" #include "jerror.h" #define ICC_MARKER … #define ICC_OVERHEAD_LEN … /* * Handy subroutine to test whether a saved marker is an ICC profile marker. */ LOCAL(boolean) marker_is_icc(jpeg_saved_marker_ptr marker) { … } /* * See if there was an ICC profile in the JPEG file being read; if so, * reassemble and return the profile data. * * TRUE is returned if an ICC profile was found, FALSE if not. If TRUE is * returned, *icc_data_ptr is set to point to the returned data, and * *icc_data_len is set to its length. * * IMPORTANT: the data at *icc_data_ptr is allocated with malloc() and must be * freed by the caller with free() when the caller no longer needs it. * (Alternatively, we could write this routine to use the IJG library's memory * allocator, so that the data would be freed implicitly when * jpeg_finish_decompress() is called. But it seems likely that many * applications will prefer to have the data stick around after decompression * finishes.) */ GLOBAL(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned int *icc_data_len) { … }