Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

colormap.h

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

Generated on Tue May 17 12:07:43 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1