iccjpeg.h 2.7 KB

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