colormap.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #if !defined COLORMAP_HEADER
00020 #define COLORMAP_HEADER
00021 
00025 
00026 #include "whiptk/whipcore.h"
00027 #include "whiptk/attribute.h"
00028 #include "whiptk/wversion.h"
00029 
00030 class WT_File;
00031 
00036 
00037 
00040 class WHIPTK_API WT_Color_Map : public WT_Attribute
00041 {
00042     friend class WT_Image;
00043     friend class WT_Pen_Pattern;
00044     friend class WT_PNG_Group4_Image;
00045         friend class WT_Rendition;
00046         friend class WT_W2D_Class_Factory;
00047         friend class WT_Opcode;
00048         friend class WT_File_Heuristics;
00049         friend class WT_DWF_Header;
00050         friend class WT_Color;
00051         friend class WT_PDFPen_Pattern;
00052 
00053 private:
00054     WT_Integer32    m_size;
00055     int                m_incarnation;
00056     enum
00057     {
00058         Getting_Count,
00059         Getting_Colors,
00060         Getting_Close_Brace
00061     }               m_stage;
00062     WT_RGBA32 *        m_map;
00063 
00064     WT_Result        serialize_just_colors (WT_File & file) const;
00065     WT_Result        materialize_just_colors(WT_Opcode const & opcode, WT_Boolean use_binary, WT_Boolean get_close_brace, WT_File & file);
00066 
00067 public:
00068 
00070     WT_Color_Map(
00071         int file_revision_being_used = REVISION_WHEN_DEFAULT_COLORMAP_WAS_CHANGED 
00072         ) throw(WT_Result);
00074     WT_Color_Map(
00075         int count, 
00076         WT_RGBA32 const * map, 
00077         WT_File & file 
00078         ) throw(WT_Result);
00080     WT_Color_Map(
00081         int count, 
00082         WT_RGB const * map, 
00083         WT_File & file 
00084         ) throw(WT_Result);
00086     WT_Color_Map(WT_Color_Map const & cmap) throw(WT_Result);
00088     virtual ~WT_Color_Map();
00089 
00090 public:
00092 
00094     void      clear();
00096     int  closest_index(WT_Color const & desired) const;
00097 
00099     int  exact_index(WT_Color const & desired) const;
00100 
00102     int exact_index(WT_RGBA32 const & rgba) const;
00103 
00105     WT_RGBA32 * map() const
00106     {    return m_map;   }
00107 
00109 
00112     WT_RGBA32 map(WT_Byte index) const
00113     {
00114         WD_Assert (index < m_size);
00115 
00116         if (index < m_size)
00117             return m_map[index];
00118         else
00119             return WT_RGBA32(0,0,0,255);
00120     }
00121 
00123     WT_Result    set(
00124         int count, 
00125         WT_RGBA32 const * map, 
00126         WT_File & file 
00127         );
00129     WT_Result     set(
00130         int count, 
00131         WT_RGB const * map, 
00132         WT_File & file 
00133         );
00134 
00136     int size() const
00137     {   return m_size;  }
00138 
00140     WT_Color_Map const & operator=(WT_Color_Map const & cmap) throw(WT_Result);
00141 
00143 
00145     WT_ID            object_id() const;
00146     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00147     WT_Result        process(WT_File & file);
00148     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00149     WT_Result        serialize (WT_File & file) const;
00150     WT_Result        sync (WT_File & file) const;
00151     WT_Boolean       operator== (WT_Attribute const & attrib) const;
00153 
00155 
00157     static WT_Result default_process(
00158         WT_Color_Map & item, 
00159         WT_File & file 
00160         );
00161 
00162 };
00163 
00165 
00166 #endif // COLORMAP_HEADER

Generated on Tue Jan 6 22:41:12 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5