core/vil1/file_formats/vil1_viff.h

Go to the documentation of this file.
00001 // This is core/vil1/file_formats/vil1_viff.h
00002 #ifndef vil1_viff_h_
00003 #define vil1_viff_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Loader for 1-banded Khoros 1.0 images
00010 // \author Peter Vanroose, ESAT, KULeuven.
00011 // \date 17 Feb 2000
00012 // VIFF is the "Visualization Image File Format" used by Khoros 1.0.
00013 //
00014 //\verbatim
00015 //  Modifications
00016 //  3 October 2001 Peter Vanroose - Implemented get_property("top_row_first")
00017 //  21 February 2002 Maarten Vergauwen - Added access functions for [fi]spare[12]
00018 //  5 June 2003    Peter Vanroose - bug fix for 64-bit platforms: data is 32-bit
00019 //\endverbatim
00020 
00021 #include <vil1/vil1_file_format.h>
00022 #include <vil1/vil1_image_impl.h>
00023 #include "vil1_viffheader.h"
00024 #include <vxl_config.h> // for vxl_uint_32
00025 
00026 //: Loader for VIFF files, i.e., 1-banded Khoros 1.0 images
00027 // This supports char, short, int, float and double pixel cell types.
00028 // No colour support right now.
00029 // Adapted from the version by Reinhard Koch, Nov. 19, 1996.
00030 class vil1_viff_file_format : public vil1_file_format
00031 {
00032  public:
00033   virtual char const* tag() const;
00034   virtual vil1_image_impl* make_input_image(vil1_stream* vs);
00035   virtual vil1_image_impl* make_output_image(vil1_stream* vs, int planes,
00036                                              int width,
00037                                              int height,
00038                                              int components,
00039                                              int bits_per_component,
00040                                              vil1_component_format format);
00041 };
00042 
00043 //: Generic image implementation for VIFF (Khoros) files
00044 class vil1_viff_generic_image : public vil1_image_impl
00045 {
00046   vil1_stream* is_;
00047   int width_;
00048   int height_;
00049   int maxval_;
00050   int planes_;
00051 
00052   int start_of_data_;
00053   int bits_per_component_;
00054   enum vil1_component_format format_;
00055 
00056   bool endian_consistent_;
00057   vil1_viff_xvimage header_;
00058 
00059   bool read_header();
00060   bool write_header();
00061   bool check_endian();
00062 
00063   friend class vil1_viff_file_format;
00064 
00065  public:
00066   vil1_viff_generic_image(vil1_stream* is);
00067   vil1_viff_generic_image(vil1_stream* is,
00068                           int planes,
00069                           int width,
00070                           int height,
00071                           int components,
00072                           int bits_per_component,
00073                           vil1_component_format format);
00074   ~vil1_viff_generic_image();
00075 
00076   //: Dimensions.  Planes x W x H x Components
00077   virtual int planes() const { return planes_; }
00078   virtual int width() const { return width_; }
00079   virtual int height() const { return height_; }
00080   virtual int components() const { return 1; }
00081 
00082   virtual int bits_per_component() const { return bits_per_component_; }
00083   virtual enum vil1_component_format component_format() const { return format_; }
00084 
00085   //: Copy plane PLANE of this to BUF
00086   virtual bool get_section(void* buf, int x0, int y0, int width, int height) const;
00087   //: Write BUF into image plane PLANE of this
00088   virtual bool put_section(void const* buf, int x0, int y0, int width, int height);
00089   //: Emulate a single plane image
00090   virtual vil1_image get_plane(unsigned int p) const;
00091 
00092   //: Return the image interpreted as rgb bytes.
00093   virtual bool get_section_rgb_byte(void* buf, int x0, int y0, int width, int height) const;
00094   virtual bool get_section_float(void* buf, int x0, int y0, int width, int height) const;
00095   virtual bool get_section_byte(void* buf, int x0, int y0, int width, int height) const;
00096 
00097   char const* file_format() const;
00098   bool get_property(char const *tag, void *prop = 0) const;
00099 
00100   //: User defined spare values in header
00101   vxl_uint_32 ispare1() const { return header_.ispare1;}
00102   vxl_uint_32 ispare2() const { return header_.ispare2;}
00103   float fspare1() const { return header_.fspare1;}
00104   float fspare2() const { return header_.fspare2;}
00105   void set_ispare1(vxl_uint_32 ispare1);
00106   void set_ispare2(vxl_uint_32 ispare2);
00107   void set_fspare1(float fspare1);
00108   void set_fspare2(float fspare2);
00109 };
00110 
00111 #endif // vil1_viff_h_

Generated on Sat Nov 22 05:08:29 2008 for core/vil1 by  doxygen 1.5.1