RAWK
Gigapixel Raw Image Processing Toolkit
 All Classes Functions Variables Pages
image_input.hpp
1 // RAWK Copyright (C) 2014 Robert Kooima
2 //
3 // This program is free software: you can redistribute it and/or modify it
4 // under the terms of the GNU General Public License as published by the Free
5 // Software Foundation, either version 3 of the License, or (at your option)
6 // any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but WITH-
9 // OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 // more details.
12 
13 #ifndef IMAGE_INPUT_HPP
14 #define IMAGE_INPUT_HPP
15 
16 //------------------------------------------------------------------------------
17 
19 
20 
21 class input : public image
22 {
23 public:
28 
29  input(std::string name, int start, int height, int width, int depth, char type)
30  {
31  switch (type)
32  {
33  case 'b': file = new rawb(name, start, height, width, depth, false); break;
34  case 'c': file = new rawc(name, start, height, width, depth, false); break;
35  case 'u': file = new rawu(name, start, height, width, depth, false); break;
36  case 'U': file = new rawU(name, start, height, width, depth, false); break;
37  case 's': file = new raws(name, start, height, width, depth, false); break;
38  case 'S': file = new rawS(name, start, height, width, depth, false); break;
39  case 'l': file = new rawl(name, start, height, width, depth, false); break;
40  case 'L': file = new rawL(name, start, height, width, depth, false); break;
41  case 'i': file = new rawi(name, start, height, width, depth, false); break;
42  case 'I': file = new rawI(name, start, height, width, depth, false); break;
43  case 'f': file = new rawf(name, start, height, width, depth, false); break;
44  case 'F': file = new rawF(name, start, height, width, depth, false); break;
45  case 'd': file = new rawd(name, start, height, width, depth, false); break;
46  case 'D': file = new rawD(name, start, height, width, depth, false); break;
47  }
48  }
49 
50  ~input()
51  {
52  delete file;
53  }
54 
55  virtual double get(int i, int j, int k) const
56  {
57  return (0 <= i && i < file->get_height() &&
58  0 <= j && j < file->get_width () &&
59  0 <= k && k < file->get_depth ()) ? file->get(i, j, k) : 0.0;
60  }
61 
62  virtual int get_height() const { return file->get_height(); }
63  virtual int get_width () const { return file->get_width (); }
64  virtual int get_depth () const { return file->get_depth (); }
65 
66  virtual void doc(std::ostream& out) const
67  {
68  out << "input " << file->get_name ()
69  << " " << file->get_height()
70  << " " << file->get_width ()
71  << " " << file->get_depth ();
72  }
73 
74 private:
75  raw *file;
76 };
77 
78 //------------------------------------------------------------------------------
79 
80 #endif
RAW image file.
Definition: raw.hpp:68
Signed 32-bit RAW adapter.
Definition: raw.hpp:331
Image file reader.
Definition: image_input.hpp:21
Byte-swapped single precision floating point RAW adapter.
Definition: raw.hpp:463
virtual int get_depth() const
Return the depth of this image.
Definition: image_input.hpp:64
Single precision floating point RAW adapter.
Definition: raw.hpp:445
Unigned 32-bit RAW adapter.
Definition: raw.hpp:369
virtual int get_height() const
Return the height of this image.
Definition: image_input.hpp:62
Base class for all image sources, filters, and operators.
Definition: image.hpp:20
input(std::string name, int start, int height, int width, int depth, char type)
Read a raw-formatted data file named name. Start gives the offset into the file where the pixel data ...
Definition: image_input.hpp:29
Unsigned 16-bit RAW adapter.
Definition: raw.hpp:293
Byte-swapped unsigned 16-bit RAW adapter.
Definition: raw.hpp:311
Unsigned 8-bit RAW adapter.
Definition: raw.hpp:235
Signed 8-bit RAW adapter.
Definition: raw.hpp:217
virtual int get_width() const
Return the height of this image.
Definition: image_input.hpp:63
Byte-swapped single precision floating point RAW adapter.
Definition: raw.hpp:425
Single precision floating point RAW adapter.
Definition: raw.hpp:407
Signed 16-bit RAW adapter.
Definition: raw.hpp:255
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_input.hpp:66
Byte-swapped signed 16-bit RAW adapter.
Definition: raw.hpp:273
Byte-swapped signed 32-bit RAW adapter.
Definition: raw.hpp:349
Byte-swapped unsigned 32-bit RAW adapter.
Definition: raw.hpp:387