1 /*
2  */
3 
4 /*
5 
6     Copyright (C) 2014 Ferrero Andrea
7 
8     This program is free software: you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21 
22  */
23 
24 /*
25 
26     These files are distributed with PhotoFlow - http://aferrero2707.github.io/PhotoFlow/
27 
28  */
29 
30 #ifndef PF_PADDED_OP_H
31 #define PF_PADDED_OP_H
32 
33 namespace PF
34 {
35 
36 class PaddedOpPar: public OpParBase
37 {
38   /* Function to derive the output area from the input area
39    */
transform(const VipsRect * rin,VipsRect * rout,int id)40   virtual void transform(const VipsRect* rin, VipsRect* rout, int id)
41   {
42     int pad = get_padding(id);
43     rout->left = rin->left+pad;
44     rout->top = rin->top+pad;
45     rout->width = rin->width-pad*2;
46     rout->height = rin->height-pad*2;
47   }
48 
49   /* Function to derive the area to be read from input images,
50      based on the requested output area
51   */
transform_inv(const VipsRect * rout,VipsRect * rin,int id)52   virtual void transform_inv(const VipsRect* rout, VipsRect* rin, int id)
53   {
54     int pad = get_padding(id);
55     rin->left = rout->left-pad;
56     rin->top = rout->top-pad;
57     rin->width = rout->width+pad*2;
58     rin->height = rout->height+pad*2;
59     //std::cout<<"PaddedOpPar::transform_inv: pad="<<pad
60     //    <<"  top="<<rout->top<<"->"<<rin->top
61     //    <<"  height="<<rout->height<<"->"<<rin->height
62     //    <<std::endl;
63   }
64 
65 
66 public:
67   PaddedOpPar();
68 
69   VipsImage* build(std::vector<VipsImage*>& in, int first,
70       VipsImage* imap, VipsImage* omap,
71       unsigned int& level);
72 };
73 
74 }
75 
76 #endif
77 
78 
79