vil_viff.h
Go to the documentation of this file.
1 // This is core/vil/file_formats/vil_viff.h
2 #ifndef vil_viff_file_format_h_
3 #define vil_viff_file_format_h_
4 //:
5 // \file
6 // \brief Loader for Khoros 1.0 images
7 // \author Peter Vanroose, ESAT, KULeuven.
8 // \date 17 Feb 2000
9 // VIFF is the "Visualization Image File Format" used by Khoros 1.0.
10 //
11 // \verbatim
12 // Modifications
13 // 3 Oct 2001 Peter Vanroose - Implemented get_property("top_row_first")
14 // 21 Febr 2002 Maarten Vergauwen - Added access functions for [fi]spare[12]
15 // 5 June 2003 Peter Vanroose - bug fix for 64-bit platforms: data is 32-bit
16 // 14 June 2003 Peter Vanroose - ported from vil1
17 // \endverbatim
18 #include <vil/vil_stream.h>
19 #include <vil/vil_file_format.h>
20 #include <vil/vil_image_resource.h>
21 #include "vil_viffheader.h"
22 #include <vxl_config.h> // for vxl_uint_32
23 
24 //: Loader for VIFF files, i.e., 1-banded Khoros 1.0 images
25 // This supports char, short, int, float and double pixel cell types.
26 // Adapted from the version by Reinhard Koch, Nov. 19, 1996.
28 {
29  public:
30  char const* tag() const override;
33  unsigned int ni, unsigned int nj, unsigned int nplanes,
34  vil_pixel_format format) override;
35 };
36 
37 //: Generic image implementation for VIFF (Khoros) files
39 {
41  unsigned int ni_;
42  unsigned int nj_;
43  unsigned int nplanes_;
44 
47 
50 
51  bool read_header();
52  bool write_header();
53  bool check_endian();
54 
55  friend class vil_viff_file_format;
56 
57  public:
60  unsigned int ni, unsigned int nj, unsigned int nplanes,
61  vil_pixel_format format);
62  ~vil_viff_image() override;
63 
64  //: Dimensions. Planes x W x H
65  unsigned int ni() const override { return ni_; }
66  unsigned int nj() const override { return nj_; }
67  unsigned int nplanes() const override { return nplanes_; }
68 
69  enum vil_pixel_format pixel_format() const override { return format_; }
70 
71  //: Return part of this as buffer
72  vil_image_view_base_sptr get_copy_view(unsigned int x0, unsigned int ni, unsigned int y0, unsigned int nj) const override;
73  //: Write buf into this at position (x0,y0)
74  bool put_view(vil_image_view_base const& buf, unsigned int x0, unsigned int y0) override;
75 
76  char const* file_format() const override;
77  bool get_property(char const *tag, void *prop = nullptr) const override;
78 
79  //: User defined spare values in header
80  vxl_uint_32 ispare1() const { return header_.ispare1;}
81  vxl_uint_32 ispare2() const { return header_.ispare2;}
82  float fspare1() const { return header_.fspare1;}
83  float fspare2() const { return header_.fspare2;}
84  void set_ispare1(vxl_uint_32 ispare1);
85  void set_ispare2(vxl_uint_32 ispare2);
86  void set_fspare1(float fspare1);
87  void set_fspare2(float fspare2);
88 };
89 
90 #endif // vil_viff_file_format_h_
Stream interface for VIL image loaders.
An abstract base class of smart pointers to actual image data in memory.
vil_pixel_format
Describes the type of the concrete data.
vxl_uint_32 ispare2() const
Definition: vil_viff.h:81
bool write_header()
Definition: vil_viff.cxx:199
vil_streampos start_of_data_
Definition: vil_viff.h:45
vxl_uint_32 ispare1
bool get_property(char const *tag, void *prop=nullptr) const override
Extra property information.
Definition: vil_viff.cxx:127
char const * file_format() const override
Return a string describing the file format.
Definition: vil_viff.cxx:106
vil_viff_xvimage header_
Definition: vil_viff.h:49
float fspare1() const
Definition: vil_viff.h:82
void set_fspare1(float fspare1)
Definition: vil_viff.cxx:405
unsigned int nplanes_
Definition: vil_viff.h:43
unsigned int ni_
Definition: vil_viff.h:41
Base class for image formats.
~vil_viff_image() override
Definition: vil_viff.cxx:122
vil_stream * is_
Definition: vil_viff.h:40
bool endian_consistent_
Definition: vil_viff.h:48
enum vil_pixel_format format_
Definition: vil_viff.h:46
unsigned int nj_
Definition: vil_viff.h:42
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
void set_fspare2(float fspare2)
Definition: vil_viff.cxx:420
unsigned int nj() const override
Dimensions: Planes x ni x nj.
Definition: vil_viff.h:66
vxl_uint_32 ispare2
void set_ispare1(vxl_uint_32 ispare1)
Definition: vil_viff.cxx:377
bool check_endian()
Definition: vil_viff.cxx:358
Abstract representation of an image source or image destination.
unsigned int nplanes() const override
Dimensions: Planes x ni x nj.
Definition: vil_viff.h:67
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
unsigned int ni() const override
Dimensions. Planes x W x H.
Definition: vil_viff.h:65
Loader for VIFF files, i.e., 1-banded Khoros 1.0 images.
Definition: vil_viff.h:27
void set_ispare2(vxl_uint_32 ispare2)
Definition: vil_viff.cxx:391
bool put_view(vil_image_view_base const &buf, unsigned int x0, unsigned int y0) override
Write buf into this at position (x0,y0).
Definition: vil_viff.cxx:284
vxl_int_32 vil_streampos
Definition: vil_stream.h:16
float fspare2() const
Definition: vil_viff.h:83
Representation of a generic image source or destination.
char const * tag() const override
Return a character string which uniquely identifies this format.
Definition: vil_viff.cxx:86
enum vil_pixel_format pixel_format() const override
Pixel Format.
Definition: vil_viff.h:69
Base class for image formats.
vil_image_resource_sptr make_output_image(vil_stream *vs, unsigned int ni, unsigned int nj, unsigned int nplanes, vil_pixel_format format) override
Definition: vil_viff.cxx:79
bool read_header()
Definition: vil_viff.cxx:133
Generic image implementation for VIFF (Khoros) files.
Definition: vil_viff.h:38
vil_image_resource_sptr make_input_image(vil_stream *vs) override
Attempt to make a generic_image which will read from vil_stream vs.
Definition: vil_viff.cxx:45
vil_viff_image(vil_stream *is)
Definition: vil_viff.cxx:93
vxl_uint_32 ispare1() const
User defined spare values in header.
Definition: vil_viff.h:80