SampleICC Main srcforge
Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

IccIO.h

Go to the documentation of this file.
00001 
00011 /*
00012  * The ICC Software License, Version 0.1
00013  *
00014  *
00015  * Copyright (c) 2003-2006 The International Color Consortium. All rights 
00016  * reserved.
00017  *
00018  * Redistribution and use in source and binary forms, with or without
00019  * modification, are permitted provided that the following conditions
00020  * are met:
00021  *
00022  * 1. Redistributions of source code must retain the above copyright
00023  *    notice, this list of conditions and the following disclaimer. 
00024  *
00025  * 2. Redistributions in binary form must reproduce the above copyright
00026  *    notice, this list of conditions and the following disclaimer in
00027  *    the documentation and/or other materials provided with the
00028  *    distribution.
00029  *
00030  * 3. The end-user documentation included with the redistribution,
00031  *    if any, must include the following acknowledgment:  
00032  *       "This product includes software developed by the
00033  *        The International Color Consortium (www.color.org)"
00034  *    Alternately, this acknowledgment may appear in the software itself,
00035  *    if and wherever such third-party acknowledgments normally appear.
00036  *
00037  * 4. In the absence of prior written permission, the names "ICC" and "The
00038  *    International Color Consortium" must not be used to imply that the
00039  *    ICC organization endorses or promotes products derived from this
00040  *    software.
00041  *
00042  *
00043  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00044  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00045  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00046  * DISCLAIMED.  IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
00047  * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00048  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00049  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00050  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00051  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00052  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00053  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00054  * SUCH DAMAGE.
00055  * ====================================================================
00056  *
00057  * This software consists of voluntary contributions made by many
00058  * individuals on behalf of the The International Color Consortium. 
00059  *
00060  *
00061  * Membership in the ICC is encouraged when this software is used for
00062  * commercial purposes. 
00063  *
00064  *  
00065  * For more information on The International Color Consortium, please
00066  * see <http://www.color.org/>.
00067  *  
00068  * 
00069  */
00070 
00072 // HISTORY:
00073 //
00074 // -Initial implementation by Max Derhak 5-15-2003
00075 //
00077 
00078 #if !defined(_ICCIO_H)
00079 #define _ICCIO_H
00080 
00081 #include "IccDefs.h"
00082 #include "stdio.h"
00083 
00084 #ifdef USESAMPLEICCNAMESPACE
00085 namespace sampleICC {
00086 #endif
00087 
00089 typedef enum {
00090   icSeekSet=0,  //Seek to an absolute position
00091   icSeekCur,    //Seek to relative position
00092   icSeekEnd,     //Seek relative to the ending
00093 } icSeekVal;
00094 
00103 class ICCPROFLIB_API CIccIO  
00104 {
00105 public:
00106 
00107   virtual ~CIccIO() {}
00108 
00109   virtual void Close() {}
00110 
00111   virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1) { return 0; }
00112   virtual icInt32Number Write8(void *pBuf8, icInt32Number nNum=1) { return 0; }
00113 
00114   icInt32Number ReadLine(void *pBuf8, icInt32Number nNum=256);
00115 
00116   icInt32Number Read16(void *pBuf16, icInt32Number nNum=1);
00117   icInt32Number Write16(void *pBuf16, icInt32Number nNum=1);
00118 
00119   icInt32Number Read32(void *pBuf32, icInt32Number nNum=1);
00120   icInt32Number Write32(void *pBuf32, icInt32Number nNum=1);
00121 
00122   icInt32Number Read64(void *pBuf64, icInt32Number nNum=1);
00123   icInt32Number Write64(void *pBuf64, icInt32Number nNum=1);
00124 
00125   icInt32Number Read8Float(void *pBufFloat, icInt32Number nNum=1);
00126   icInt32Number Write8Float(void *pBuf16, icInt32Number nNum=1);
00127 
00128   icInt32Number Read16Float(void *pBufFloat, icInt32Number nNum=1);
00129   icInt32Number Write16Float(void *pBuf16, icInt32Number nNum=1);
00130 
00131   icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1);
00132   icInt32Number WriteFloat32Float(void *pBuf16, icInt32Number nNum=1);
00133 
00134   virtual icInt32Number GetLength() {return 0;}
00135 
00136   virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos) {return -1;}
00137   virtual icInt32Number Tell() {return 0;}
00138 
00140   bool Align32(); 
00141 
00143   bool Sync32(icUInt32Number nOffset=0); 
00144 };
00145 
00153 class ICCPROFLIB_API CIccFileIO : public CIccIO
00154 {
00155 public:
00156   CIccFileIO();
00157   virtual ~CIccFileIO();
00158 
00159   bool Open(const icChar *szFilename, const icChar *szAttr);
00160   virtual void Close();
00161 
00162   virtual icInt32Number Read8(void *pBuf, icInt32Number nNum=1);
00163   virtual icInt32Number Write8(void *pBuf, icInt32Number nNum=1);
00164 
00165   virtual icInt32Number GetLength();
00166 
00167   virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos);
00168   virtual icInt32Number Tell();
00169 
00170 protected:
00171   FILE *m_fFile;
00172 };
00173 
00181 class ICCPROFLIB_API CIccMemIO : public CIccIO
00182 {
00183 public:
00184   CIccMemIO();
00185   virtual ~CIccMemIO();
00186 
00187   bool Alloc(icUInt32Number nSize, bool bWrite = false);
00188 
00189   bool Attach(icUInt8Number *pData, icUInt32Number nSize, bool bWrite=false);
00190   virtual void Close();
00191 
00192   virtual icInt32Number Read8(void *pBuf, icInt32Number nNum=1);
00193   virtual icInt32Number Write8(void *pBuf, icInt32Number nNum=1);
00194 
00195   virtual icInt32Number GetLength();
00196 
00197   virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos);
00198   virtual icInt32Number Tell();
00199 
00200   icUInt8Number *GetData() { return m_pData; }
00201 
00202 protected:
00203   icUInt8Number *m_pData;
00204   icUInt32Number m_nSize;
00205   icUInt32Number m_nAvail;
00206   icUInt32Number m_nPos;
00207 
00208   bool m_bFreeData;
00209 };
00210 
00211 #ifdef USESAMPLEICCNAMESPACE
00212 } //namespace sampleICC
00213 #endif
00214 
00215 #endif // !defined(_ICCIO_H)

Generated on Tue Jun 26 17:51:43 2007 for IccProfLib by  doxygen 1.3.9.1