iccjpeg.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * iccprofile.h
  3. *
  4. * Copyright (C) 1991-1998, Thomas G. Lane.
  5. * This file is part of the Independent JPEG Group's software.
  6. * For conditions of distribution and use, see the accompanying README file.
  7. *
  8. * This file provides code to read and write International Color Consortium
  9. * (ICC) device profiles embedded in JFIF JPEG image files. The ICC has
  10. * defined a standard format for including such data in JPEG "APP2" markers.
  11. * The code given here does not know anything about the internal structure
  12. * of the ICC profile data; it just knows how to put the profile data into
  13. * a JPEG file being written, or get it back out when reading.
  14. *
  15. * This code depends on new features added to the IJG JPEG library as of
  16. * IJG release 6b; it will not compile or work with older IJG versions.
  17. *
  18. * NOTE: this code would need surgery to work on 16-bit-int machines
  19. * with ICC profiles exceeding 64K bytes in size. See iccprofile.c
  20. * for details.
  21. */
  22. #include <stdio.h> /* needed to define "FILE", "NULL" */
  23. #if defined(USE_SYSTEM_LIBJPEG)
  24. #include <jpeglib.h>
  25. #else
  26. #include "jpeglib.h"
  27. #endif
  28. /*
  29. * This routine writes the given ICC profile data into a JPEG file.
  30. * It *must* be called AFTER calling jpeg_start_compress() and BEFORE
  31. * the first call to jpeg_write_scanlines().
  32. * (This ordering ensures that the APP2 marker(s) will appear after the
  33. * SOI and JFIF or Adobe markers, but before all else.)
  34. */
  35. extern void write_icc_profile JPP((j_compress_ptr cinfo,
  36. const JOCTET *icc_data_ptr,
  37. unsigned int icc_data_len));
  38. /*
  39. * Reading a JPEG file that may contain an ICC profile requires two steps:
  40. *
  41. * 1. After jpeg_create_decompress() but before jpeg_read_header(),
  42. * call setup_read_icc_profile(). This routine tells the IJG library
  43. * to save in memory any APP2 markers it may find in the file.
  44. *
  45. * 2. After jpeg_read_header(), call read_icc_profile() to find out
  46. * whether there was a profile and obtain it if so.
  47. */
  48. /*
  49. * Prepare for reading an ICC profile
  50. */
  51. extern void setup_read_icc_profile JPP((j_decompress_ptr cinfo));
  52. /*
  53. * See if there was an ICC profile in the JPEG file being read;
  54. * if so, reassemble and return the profile data.
  55. *
  56. * TRUE is returned if an ICC profile was found, FALSE if not.
  57. * If TRUE is returned, *icc_data_ptr is set to point to the
  58. * returned data, and *icc_data_len is set to its length.
  59. *
  60. * IMPORTANT: the data at **icc_data_ptr has been allocated with malloc()
  61. * and must be freed by the caller with free() when the caller no longer
  62. * needs it. (Alternatively, we could write this routine to use the
  63. * IJG library's memory allocator, so that the data would be freed implicitly
  64. * at jpeg_finish_decompress() time. But it seems likely that many apps
  65. * will prefer to have the data stick around after decompression finishes.)
  66. */
  67. extern boolean read_icc_profile JPP((j_decompress_ptr cinfo,
  68. JOCTET **icc_data_ptr,
  69. unsigned int *icc_data_len));