RAWK
Gigapixel Raw Image Processing Toolkit
 All Classes Functions Variables Pages
image_paste.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_PASTE_HPP
14 #define IMAGE_PASTE_HPP
15 
16 //------------------------------------------------------------------------------
17 
19 
20 class paste : public image
21 {
22 public:
28 
29  paste(int row, int column, image *L, image *R)
30  : image(L, R), row(row), column(column) { }
31 
32  virtual double get(int i, int j, int k) const
33  {
34  if (row <= i && i < row + L->get_height() &&
35  column <= j && j < column + L->get_width())
36 
37  return L->get(i - row, j - column, k);
38  else
39  return R->get(i, j, k);
40  }
41 
42  virtual int get_height() const
43  {
44  return std::max(L->get_height() + row, R->get_height());
45  }
46 
47  virtual int get_width () const
48  {
49  return std::max(L->get_width() + column, R->get_width());
50  }
51 
52  virtual void doc(std::ostream& out) const
53  {
54  out << "paste " << row << " " << column;
55  }
56 
57 private:
58  int row;
59  int column;
60 };
61 
62 //------------------------------------------------------------------------------
63 
64 #endif
virtual double get(int i, int j, int k) const =0
Return the value of the sample at row i, column j, channel k.
image * L
Left child.
Definition: image.hpp:117
virtual int get_height() const
Return the height of this image.
Definition: image_paste.hpp:42
Base class for all image sources, filters, and operators.
Definition: image.hpp:20
virtual int get_height() const
Return the height of this image.
Definition: image.hpp:46
Overlay operator.
Definition: image_paste.hpp:20
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_paste.hpp:52
virtual int get_width() const
Return the height of this image.
Definition: image.hpp:56
virtual int get_width() const
Return the height of this image.
Definition: image_paste.hpp:47
image * R
Right child.
Definition: image.hpp:118
paste(int row, int column, image *L, image *R)
Paste image L over image R. Row and column give the position of the top-left corner of the pasted ima...
Definition: image_paste.hpp:29