~ubuntu-branches/ubuntu/karmic/photoprint/karmic

« back to all changes in this revision

Viewing changes to imagesource/iccjpeg.h

  • Committer: Bazaar Package Importer
  • Author(s): Milan Zamazal
  • Date: 2007-05-01 16:32:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070501163213-ni1933khtg9fdvn5
Tags: 0.3.5-2
Move to unstable.

Show diffs side-by-side

added added

removed removed

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