Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccIO.h
Go to the documentation of this file.
1/** @file
2 File: IccIO.h
3
4 Contains: Implementation of the CIccIO class.
5
6 Version: V1
7
8 Copyright: (c) see ICC Software License
9*/
10
11/*
12 * The ICC Software License, Version 0.2
13 *
14 *
15 * Copyright (c) 2003-2012 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#if !defined(_ICCIO_H)
72#define _ICCIO_H
73
74#include "IccDefs.h"
75#include "stdio.h"
76
77#ifdef USEREFICCMAXNAMESPACE
78namespace refIccMAX {
79#endif
80
81///Seek types
82typedef enum {
83 icSeekSet=0, //Seek to an absolute position
84 icSeekCur, //Seek to relative position
85 icSeekEnd, //Seek relative to the ending
86} icSeekVal;
87
88/**
89 **************************************************************************
90 * Type: Class
91 *
92 * Purpose:
93 * This is the base object that handles the IO with an ICC profile.
94 **************************************************************************
95 */
97{
98public:
99
100 virtual ~CIccIO() {}
101
102 virtual void Close() {}
103
104 virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1) { return 0; }
105 virtual icInt32Number Write8(void *pBuf8, icInt32Number nNum=1) { return 0; }
106
107 icInt32Number ReadLine(void *pBuf8, icInt32Number nNum=256);
108
109 icInt32Number Read16(void *pBuf16, icInt32Number nNum=1);
110 icInt32Number Write16(void *pBuf16, icInt32Number nNum=1);
111
112 icInt32Number Read32(void *pBuf32, icInt32Number nNum=1);
113 icInt32Number Write32(void *pBuf32, icInt32Number nNum=1);
114
115 icInt32Number Read64(void *pBuf64, icInt32Number nNum=1);
116 icInt32Number Write64(void *pBuf64, icInt32Number nNum=1);
117
118 icInt32Number ReadUInt8Float(void *pBufFloat, icInt32Number nNum=1);
119 icInt32Number WriteUInt8Float(void *pBuf16, icInt32Number nNum=1);
120
121 icInt32Number ReadUInt16Float(void *pBufFloat, icInt32Number nNum=1);
122 icInt32Number WriteUInt16Float(void *pBuf16, icInt32Number nNum=1);
123
124 icInt32Number ReadFloat16Float(void *pBufFloat, icInt32Number nNum=1);
125 icInt32Number WriteFloat16Float(void *pBuf16, icInt32Number nNum=1);
126
127 icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1);
128 icInt32Number WriteFloat32Float(void *pBufFloat, icInt32Number nNum=1);
129
130 virtual icInt32Number GetLength() {return 0;}
131
132 virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos) {return -1;}
133 virtual icInt32Number Tell() {return 0;}
134
135 ///Write operation to make sure that filelength is evenly divisible by 4
136 bool Align32();
137
138 ///Operation to make sure read position is evenly divisible by 4
139 bool Sync32(icUInt32Number nOffset=0);
140};
141
142/**
143 **************************************************************************
144 * Type: Class
145 *
146 * Purpose: Handles generic File IO
147 **************************************************************************
148 */
150{
151public:
152 CIccFileIO();
153 virtual ~CIccFileIO();
154
155 bool Open(const icChar *szFilename, const icChar *szAttr);
156#ifdef WIN32
157 bool Open(const icWChar *szFilename, const icWChar *szAttr);
158#endif
159
160 bool Attach(FILE *f);
161 void Detach();
162
163 virtual void Close();
164
165 virtual icInt32Number Read8(void *pBuf, icInt32Number nNum=1);
166 virtual icInt32Number Write8(void *pBuf, icInt32Number nNum=1);
167
168 virtual icInt32Number GetLength();
169
170 virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos);
171 virtual icInt32Number Tell();
172
173protected:
174 FILE *m_fFile;
175};
176
177/**
178**************************************************************************
179* Type: Class
180*
181* Purpose: Handles embedding a file within a file
182**************************************************************************
183*/
185{
186public:
187 CIccEmbedIO();
188 virtual ~CIccEmbedIO();
189
190 bool Attach(CIccIO *pIO, icInt32Number nSize=0, bool bOwnIO=false);
191 virtual void Close();
192
193 virtual icInt32Number Read8(void *pBuf, icInt32Number nNum = 1);
194 virtual icInt32Number Write8(void *pBuf, icInt32Number nNum = 1);
195
196 virtual icInt32Number GetLength();
197
198 virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos);
199 virtual icInt32Number Tell();
200
201protected:
206};
207
208
209/**
210 **************************************************************************
211 * Type: Class
212 *
213 * Purpose: Handles generic memory IO
214 **************************************************************************
215 */
217{
218public:
219 CIccMemIO();
220 virtual ~CIccMemIO();
221
222 bool Alloc(icUInt32Number nSize, bool bWrite = false);
223
224 bool Attach(icUInt8Number *pData, icUInt32Number nSize, bool bWrite=false);
225 virtual void Close();
226
227 virtual icInt32Number Read8(void *pBuf, icInt32Number nNum=1);
228 virtual icInt32Number Write8(void *pBuf, icInt32Number nNum=1);
229
230 virtual icInt32Number GetLength();
231
232 virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos);
233 virtual icInt32Number Tell();
234
235 icUInt8Number *GetData() { return m_pData; }
236
237protected:
242
244};
245
246/**
247 **************************************************************************
248 * Type: Class
249 *
250 * Purpose: Handles simulated File IO
251 **************************************************************************
252 */
254{
255public:
256 CIccNullIO();
257 virtual ~CIccNullIO();
258
259 //Open resets the file to being zero size
260 void Open();
261 virtual void Close();
262
263
264 virtual icInt32Number Read8(void *pBuf, icInt32Number nNum=1); //Read zero's into buf
265 virtual icInt32Number Write8(void *pBuf, icInt32Number nNum=1);
266
267 virtual icInt32Number GetLength();
268
269 virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos);
270 virtual icInt32Number Tell();
271
272protected:
275};
276
277
278#ifdef USEREFICCMAXNAMESPACE
279} //namespace refIccMAX
280#endif
281
282#endif // !defined(_ICCIO_H)
File: IccDefs.h
char icChar
Definition IccDefs.h:109
icSeekVal
Seek types.
Definition IccIO.h:82
@ icSeekEnd
Definition IccIO.h:85
@ icSeekSet
Definition IccIO.h:83
@ icSeekCur
Definition IccIO.h:84
#define ICCPROFLIB_API
unsigned int icUInt32Number
Type: Class.
Definition IccIO.h:185
bool m_bOwnIO
Definition IccIO.h:205
icInt32Number m_nSize
Definition IccIO.h:204
icInt32Number m_nStartPos
Definition IccIO.h:203
CIccIO * m_pIO
Definition IccIO.h:202
Type: Class.
Definition IccIO.h:150
FILE * m_fFile
Definition IccIO.h:174
Type: Class.
Definition IccIO.h:97
virtual icInt32Number Write8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:105
virtual icInt32Number GetLength()
Definition IccIO.h:130
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:104
virtual icInt32Number Tell()
Definition IccIO.h:133
virtual ~CIccIO()
Definition IccIO.h:100
virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos)
Definition IccIO.h:132
virtual void Close()
Definition IccIO.h:102
Type: Class.
Definition IccIO.h:217
icUInt32Number m_nPos
Definition IccIO.h:241
icUInt32Number m_nSize
Definition IccIO.h:239
icUInt8Number * GetData()
Definition IccIO.h:235
icUInt32Number m_nAvail
Definition IccIO.h:240
bool m_bFreeData
Definition IccIO.h:243
icUInt8Number * m_pData
Definition IccIO.h:238
Type: Class.
Definition IccIO.h:254
icUInt32Number m_nPos
Definition IccIO.h:274
icUInt32Number m_nSize
Definition IccIO.h:273
unsigned char icUInt8Number
Number definitions.
long icInt32Number