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

image.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 IMAGE_HEADER
00019 #define IMAGE_HEADER
00020 
00021 #include "whiptk/whipcore.h"
00022 #include "whiptk/file.h"
00023 #include "whiptk/drawable.h"
00024 
00025 #define WD_EXPECTED_GROUP3X_FACTOR  0.2
00026 
00028 class WT_Huffman
00029 {
00030 public:
00031 
00033     enum Bitonal_Value
00034     {
00035         Background = 0, 
00036         Foreground = 1  
00037     };
00038 
00040     enum Raster_Encoding
00041     {
00042         Group3 = 0x00,
00043         Group3X = 0x01,
00044         Literal = 0x02,
00045         Reserved = 0x03
00046     };
00047 
00049     int run;
00050 
00052     struct Code
00053     {
00054         WT_Byte    value;
00055         WT_Byte    length;
00056     }           code[2];
00057 };
00058 
00063 
00064 
00068 class WHIPTK_API WT_Image : public WT_Drawable
00069 {
00070 public:
00072     enum WT_Image_Format
00073     {
00074         Bitonal_Mapped      = WD_IMAGE_BITONAL_MAPPED_EXT_OPCODE,
00075         Group3X_Mapped      = WD_IMAGE_GROUP3X_MAPPED_EXT_OPCODE,
00076         Indexed             = WD_IMAGE_INDEXED_EXT_OPCODE,
00077         Mapped              = WD_IMAGE_MAPPED_EXT_OPCODE,
00078         RGB                 = WD_IMAGE_RGB_EXT_OPCODE,
00079         RGBA                = WD_IMAGE_RGBA_EXT_OPCODE,
00080         JPEG                = WD_IMAGE_JPEG_EXT_OPCODE
00081     };
00082 
00083 private:
00084 
00085     WT_Unsigned_Integer16   m_rows;
00086     WT_Unsigned_Integer16   m_columns;
00087     WT_Byte                 m_format;
00088     WT_Integer32            m_identifier;
00089 
00090     WT_Color_Map *          m_color_map;
00091     WT_Integer32            m_data_size;
00092     WT_Byte *               m_data;
00093 
00094     WT_Logical_Point        m_min_corner;
00095     WT_Logical_Point        m_max_corner;
00096 
00097     WT_Boolean              m_transformed;
00098     WT_Boolean              m_relativized;
00099     WT_Boolean              m_local_data_copy;
00100     WT_Boolean              m_local_color_map_copy;
00101 
00102     // Scratchpad for conversion method use
00103     WT_Byte *               m_source_data;
00104     int                     m_src_byte_position;
00105     int                     m_src_bits_used;
00106     int                     m_dst_bits_used;
00107     int                     m_data_allocated;
00108 
00109     enum
00110     {
00111         Starting,
00112         Getting_Columns,
00113         Getting_Col_Row_Comma,
00114         Getting_Rows,
00115         Getting_Min_Corner,
00116         Getting_Max_Corner,
00117         Getting_Format,
00118         Getting_Identifier,
00119         Getting_Color_Map_Opcode,
00120         Getting_Color_Map,
00121         Getting_Pre_Data_Size_Whitespace,
00122         Getting_Pre_Data_Size_Open_Paren,
00123         Getting_Data_Size,
00124         Getting_Data,
00125         Getting_Close
00126     }                       m_stage;
00127 
00128     WT_Opcode               m_colormap_opcode;
00129 
00130     WT_Image (WT_Image const &)
00131       : WT_Drawable()
00132       , m_rows()
00133       , m_columns()
00134       , m_format()
00135       , m_identifier()
00136       , m_color_map()
00137       , m_data_size()
00138       , m_data()
00139       , m_min_corner()
00140       , m_max_corner()
00141       , m_transformed()
00142       , m_relativized()
00143       , m_local_data_copy()
00144       , m_local_color_map_copy()
00145       , m_source_data()
00146       , m_src_byte_position()
00147       , m_src_bits_used()
00148       , m_dst_bits_used()
00149       , m_data_allocated()
00150       , m_stage()
00151       , m_colormap_opcode()
00152     {
00153         WD_Complain ("cannot copy WT_Image");
00154     } // prohibited
00155 
00156     WT_Image & operator= (WT_Image const &)
00157     {
00158         WD_Complain ("cannot assign WT_Image");
00159         return *this;
00160     } // prohibited
00161 
00162     inline WT_Result        add_code (WT_Huffman::Code const & code);
00163     inline int              get_next_bit();
00164     inline WT_Result        output_group3x_code(int run_color, int run_length, WT_Boolean skip_trailing_zero);
00165 
00166 public:
00167 
00168     // Constructors, Destructors
00169 
00171     WT_Image ()
00172                 : m_rows(0)
00173                 , m_columns(0)
00174                 , m_format(RGBA)
00175                 , m_identifier(0)
00176                 , m_color_map(WD_Null)
00177                 , m_data_size(0)
00178                 , m_data(WD_Null)
00179                 , m_min_corner(0,0)
00180                 , m_max_corner(0,0)
00181                 , m_transformed(WD_False)
00182                 , m_relativized(WD_False)
00183                 , m_local_data_copy(WD_False)
00184                 , m_local_color_map_copy(WD_False)
00185                 , m_stage(Starting)
00186             { }
00187 
00189     WT_Image (int image_type)
00190                 : m_rows(0)
00191                 , m_columns(0)
00192                 , m_format(static_cast<WT_Byte>(image_type))
00193                 , m_identifier(0)
00194                 , m_color_map(WD_Null)
00195                 , m_data_size(0)
00196                 , m_data(WD_Null)
00197                 , m_min_corner(0,0)
00198                 , m_max_corner(0,0)
00199                 , m_transformed(WD_False)
00200                 , m_relativized(WD_False)
00201                 , m_local_data_copy(WD_False)
00202                 , m_local_color_map_copy(WD_False)
00203                 , m_stage(Getting_Columns)
00204             { }
00205 
00206 
00208     WT_Image(
00209             WT_Unsigned_Integer16       rows, 
00210             WT_Unsigned_Integer16       columns, 
00211             WT_Image_Format             format, 
00212             WT_Integer32                identifier, 
00213             WT_Color_Map const *        color_map, 
00214             WT_Integer32                data_size, 
00215             WT_Byte *                   data, 
00216             WT_Logical_Point const &    min_corner, 
00217             WT_Logical_Point const &    max_corner, 
00218             WT_Boolean                  copy 
00219             );
00220 
00222     ~WT_Image()
00223     {
00224         if (m_local_data_copy)
00225             delete [] m_data;
00226 
00227         if (m_local_color_map_copy)
00228             delete m_color_map;
00229     }
00230 
00231 
00233 
00234     WT_Color_Map const * color_map() const
00235     {   return m_color_map;     }
00237     WT_Unsigned_Integer16 columns() const
00238     {   return m_columns;  }
00240     WT_Byte const * data() const
00241     {   return m_data;  }
00243     WT_Integer32 data_size() const
00244     {   return m_data_size; }
00246     WT_Byte format() const
00247     {   return m_format;  }
00249     WT_Integer32 identifier() const
00250     {   return m_identifier;    }
00252     WT_Logical_Point const & max_corner() const
00253     {   return m_max_corner;    }
00255     WT_Logical_Point const & min_corner() const
00256     {   return m_min_corner;    }
00258     WT_Unsigned_Integer16 rows() const
00259     {   return m_rows;  }
00261 
00263 
00264 
00268     WT_Result      convert_bitonal_to_group_3X ();
00270 
00273     WT_Result      convert_group_3X_to_bitonal();
00275 
00278     WT_Result      convert_group_3X_to_mapped();
00280 
00282 
00283     void        de_relativize(WT_File & file);
00285     void        relativize(WT_File & file);
00287     void           transform(WT_Transform const & transform);
00289 
00291     WT_ID            object_id() const;
00292     WT_Result        serialize(WT_File & file) const;
00293     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00294     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00295     WT_Result        process(WT_File & file);
00296     virtual void     update_bounds(WT_File * file);
00298 
00300 
00302     static WT_Result default_process(
00303         WT_Image & item, 
00304         WT_File & file 
00305         );
00306 };
00307 
00308 #endif // IMAGE_HEADER

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