Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
iccTiffDump.cpp
Go to the documentation of this file.
1/*
2 File: iccTiffDump.cpp
3
4 Contains: Console app display info about Tiff file and its ICC profile
5
6 Version: V1
7
8 Copyright: (c) see below
9*/
10
11/*
12 * The ICC Software License, Version 0.2
13 *
14 *
15 * Copyright (c) 2003-2010 The International Color Consortium. All rights
16 * reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 *
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in
27 * the documentation and/or other materials provided with the
28 * distribution.
29 *
30 * 3. In the absence of prior written permission, the names "ICC" and "The
31 * International Color Consortium" must not be used to imply that the
32 * ICC organization endorses or promotes products derived from this
33 * software.
34 *
35 *
36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
40 * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This software consists of voluntary contributions made by many
51 * individuals on behalf of the The International Color Consortium.
52 *
53 *
54 * Membership in the ICC is encouraged when this software is used for
55 * commercial purposes.
56 *
57 *
58 * For more information on The International Color Consortium, please
59 * see <http://www.color.org/>.
60 *
61 *
62 */
63
64//////////////////////////////////////////////////////////////////////
65// HISTORY:
66//
67// -Initial implementation by Max Derhak 5-15-2003
68//
69//////////////////////////////////////////////////////////////////////
70
71
72#include <stdio.h>
73#include "IccCmm.h"
74#include "IccUtil.h"
75#include "IccDefs.h"
76#include "IccProfLibVer.h"
77#include "IccApplyBPC.h"
78#include "TiffImg.h"
79
80
81typedef struct {
82 unsigned long nId;
83 char const * const szName;
84} IdList;
85#define UNKNOWNID 0xffffffff
86
87
89 {0, "Interleaved samples"},
90 {PLANARCONFIG_CONTIG, "Interleaved samples"},
91 {PLANARCONFIG_SEPARATE, "Samples in separate planes"},
92
93 {UNKNOWNID, "Unknown"},
94};
95
97 {PHOTO_MINISWHITE, "Min Is White"},
98 {PHOTO_MINISBLACK, "Min Is Black"},
99 {PHOTO_CIELAB, "CIELab"},
100 {PHOTO_ICCLAB, "IccLab"},
101
102 {UNKNOWNID, "Unknown"},
103};
104
106 {COMPRESSION_NONE, "None"},
107 {COMPRESSION_LZW, "LZW"},
108 {COMPRESSION_JPEG, "JPEG"},
109 {COMPRESSION_DEFLATE, "Deflate"},
110 {COMPRESSION_ADOBE_DEFLATE, "Deflate"},
111
112 {UNKNOWNID, "Unknown"},
113};
114
115const char* GetId(unsigned long nId, IdList* pIdList)
116{
117 for (;pIdList->nId != nId && pIdList->nId != UNKNOWNID; pIdList++);
118
119 return pIdList->szName;
120}
121
122
123void Usage()
124{
125 printf("iccTiffDump built with IccProfLib version " ICCPROFLIBVER "\n\n");
126
127 printf("Usage: iccTiffDump tiff_file {exported_icc_file}\n\n");
128}
129
130//===================================================
131
132int main(int argc, icChar* argv[])
133{
134 int minargs = 1; // minimum number of arguments
135 if(argc<=minargs) {
136 Usage();
137 return -1;
138 }
139
140 CTiffImg SrcImg;
141
142 if (!SrcImg.Open(argv[1])) {
143 printf("\nFile [%s] cannot be opened.\n", argv[1]);
144 return false;
145 }
146
147 printf("-------------------->Tiff Image Dump<---------------------------\n");
148 printf("Filename: %s\n", argv[1]);
149 printf("Size: (%d x %d) pixels, (%.2lf\" x %.2lf\")\n",
150 SrcImg.GetWidth(), SrcImg.GetHeight(),
151 SrcImg.GetWidthIn(), SrcImg.GetHeightIn());
152 printf("Planar: %s\n", GetId(SrcImg.GetPlanar(), planar_types));
153 printf("BitsPerSample: %d\n", SrcImg.GetBitsPerSample());
154 printf("SamplesPerPixel: %d\n", SrcImg.GetSamples());
155 int nExtra = SrcImg.GetExtraSamples();
156 if (nExtra)
157 printf("ExtraSamples %d\n", nExtra);
158 printf("Photometric: %s\n", GetId(SrcImg.GetPhoto(), photo_types));
159 printf("BytesPerLine: %d\n", SrcImg.GetBytesPerLine());
160
161 printf("Resolution: (%lf x %lf) pixels per/inch\n", SrcImg.GetXRes(), SrcImg.GetYRes());
162 printf("Compression: %s\n", GetId(SrcImg.GetCompress(), compression_types));
163
164 unsigned char *pProfMem;
165 unsigned int nLen;
166 if (SrcImg.GetIccProfile(pProfMem, nLen)) {
167 printf("Profile: Embedded\n");
168
169 CIccProfile *pProfile = OpenIccProfile(pProfMem, nLen);
170
171 if (pProfile) {
172 icHeader *pHdr = &pProfile->m_Header;
173 CIccInfo Fmt;
174
175 if (pHdr->colorSpace)
176 printf(" Color Space: %s\n", Fmt.GetColorSpaceSigName(pHdr->colorSpace));
177 if (pHdr->pcs)
178 printf(" Colorimetric PCS: %s\n", Fmt.GetColorSpaceSigName(pHdr->pcs));
179 if (pHdr->spectralPCS) {
180 printf(" Spectral PCS: %s\n", Fmt.GetSpectralColorSigName(pHdr->spectralPCS));
181 if (pHdr->spectralRange.start || pHdr->spectralRange.end || pHdr->spectralRange.steps) {
182 printf(" Spectral Range: start=%.1fnm, end=%.1fnm, steps=%d\n",
185 pHdr->spectralRange.steps);
186 }
187 if (pHdr->biSpectralRange.start || pHdr->biSpectralRange.end || pHdr->biSpectralRange.steps) {
188 printf(" BiSpectral Range: start=%.1fnm, end=%.1fnm, steps=%d\n",
191 pHdr->biSpectralRange.steps);
192 }
193 }
194 CIccTag *pDesc = pProfile->FindTag(icSigProfileDescriptionTag);
195 if (pDesc->GetType()==icSigTextDescriptionType) {
197 printf(" Description: %s\n", pText->GetText());
198 }
199 else if (pDesc->GetType()==icSigMultiLocalizedUnicodeType) {
201 if (pStrs->m_Strings) {
202 CIccMultiLocalizedUnicode::iterator text = pStrs->m_Strings->begin();
203 if (text != pStrs->m_Strings->end()) {
204 std::string line;
205 text->GetText(line);
206 printf(" Description: %s\n", line.c_str());
207 }
208 }
209 }
210 }
211 }
212 else {
213 printf("Profile: Embedded\n");
214 }
215
216 SrcImg.Close();
217 return 0;
218}
219
File: IccApplyBPC.h.
File: IccCmm.h.
File: IccDefs.h
char icChar
Definition IccDefs.h:109
#define ICCPROFLIBVER
CIccProfile * OpenIccProfile(const icChar *szFilename, bool bUseSubProfile)
Name: OpenIccProfile.
icFloatNumber icF16toF(icFloat16Number num)
Definition IccUtil.cpp:629
File: IccUtil.h.
int main()
Core and external libraries necessary for the fuzzer functionality.
#define PHOTO_CIELAB
Definition TiffImg.h:80
#define PHOTO_MINISBLACK
Definition TiffImg.h:78
#define PHOTO_ICCLAB
Definition TiffImg.h:81
#define PHOTO_MINISWHITE
Definition TiffImg.h:79
Type: Class.
Definition IccUtil.h:303
const icChar * GetSpectralColorSigName(icSpectralColorSignature sig)
Definition IccUtil.cpp:1769
const icChar * GetColorSpaceSigName(icColorSpaceSignature sig)
Definition IccUtil.cpp:1640
Class: CIccTag.
virtual icTagTypeSignature GetType() const
Function: GetType()
Class: CIccTagMultiLocalizedUnicode.
CIccMultiLocalizedUnicode * m_Strings
Class: CIccTagTextDescription()
const icChar * GetText() const
float GetYRes()
Definition TiffImg.h:110
bool Open(const char *szFname)
Definition TiffImg.cpp:228
void Close()
Definition TiffImg.cpp:104
unsigned int GetBitsPerSample()
Definition TiffImg.h:103
unsigned int GetWidth()
Definition TiffImg.h:99
unsigned int GetPlanar()
Definition TiffImg.h:108
double GetHeightIn()
Definition TiffImg.h:102
double GetWidthIn()
Definition TiffImg.h:101
float GetXRes()
Definition TiffImg.h:109
unsigned int GetPhoto()
Definition TiffImg.cpp:391
unsigned int GetSamples()
Definition TiffImg.h:105
unsigned int GetExtraSamples()
Definition TiffImg.h:106
unsigned int GetHeight()
Definition TiffImg.h:100
unsigned int GetBytesPerLine()
Definition TiffImg.h:112
bool GetIccProfile(unsigned char *&pProfile, unsigned int &nLen)
Definition TiffImg.cpp:410
unsigned int GetCompress()
Definition TiffImg.h:107
@ icSigMultiLocalizedUnicodeType
@ icSigTextDescriptionType
@ icSigProfileDescriptionTag
void Usage()
const char * GetId(unsigned long nId, IdList *pIdList)
IdList planar_types[]
IdList photo_types[]
#define UNKNOWNID
IdList compression_types[]
unsigned long nId
char const *const szName
The Profile header.
icSpectralRange spectralRange
icColorSpaceSignature colorSpace
icSpectralColorSignature spectralPCS
icSpectralRange biSpectralRange
icColorSpaceSignature pcs
icUInt16Number steps
icFloat16Number start
icFloat16Number end