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_PERSPECTIVE_H
31 #define PF_PERSPECTIVE_H
32 
33 #include <string>
34 
35 #include "../base/property.hh"
36 #include "../base/operation.hh"
37 #include "../base/processor.hh"
38 
39 namespace PF
40 {
41 
42 class PerspectivePar: public OpParBase
43 {
44   Property< std::vector<std::pair<float,float> > > keystones;
45 
46 public:
47   PerspectivePar();
48 
has_opacity()49   bool has_opacity() { return false; }
has_intensity()50   bool has_intensity() { return false; }
51 
get_keystones()52   std::vector< std::pair<float,float> >& get_keystones() { return keystones.get(); }
53 
54   /* Function to derive the output area from the input area
55    *//*
56   virtual void transform(const Rect* rin, Rect* rout)
57   {
58     int in_w2 = in_width/2;
59     int in_h2 = in_height/2;
60     int out_w2 = out_width/2;
61     int out_h2 = out_height/2;
62     float xout = cos_angle*(rin->left-in_w2) - sin_angle*(rin->top-in_h2) + out_w2 - crop.left;
63     float yout = sin_angle*(rin->left-in_w2) + cos_angle*(rin->top-in_h2) + out_h2 - crop.top;
64     //std::cout<<"xout="<<xout<<" = "<<cos_angle<<"*("<<rin->left<<"-"<<in_w2<<") - "<<sin_angle<<"*("<<rin->top<<"-"<<in_h2<<") + "<<out_w2<<std::endl;
65     //std::cout<<"sin_angle="<<sin_angle<<" cos_angle="<<cos_angle<<"  xout="<<xout<<" yout="<<yout<<std::endl;
66     rout->left = xout*scale_mult;
67     rout->top = yout*scale_mult;
68     rout->width = rin->width*scale_mult;
69     rout->height = rin->height*scale_mult;
70   }
71   */
72 
73   /* Function to derive the area to be read from input images,
74        based on the requested output area
75   *//*
76   virtual void transform_inv(const Rect* rout, Rect* rin)
77   {
78     float minus = -1.0;
79     int in_w2 = in_width/2;
80     int in_h2 = in_height/2;
81     int out_w2 = out_width/2;
82     int out_h2 = out_height/2;
83     float xin = cos_angle*(rout->left-out_w2) + sin_angle*(rout->top-out_h2) + in_w2 + crop.left;
84     float yin = minus*sin_angle*(rout->left-out_w2) + cos_angle*(rout->top-out_h2) + in_h2 + crop.top;
85     //std::cout<<"xin="<<xin<<" = "<<cos_angle<<"*("<<rout->left<<"-"<<out_w2<<") - "<<sin_angle<<"*("<<rout->top<<"-"<<out_h2<<") + "<<in_w2<<std::endl;
86     //std::cout<<"sin_angle="<<sin_angle<<" cos_angle="<<cos_angle<<"  xin="<<xin<<" yin="<<yin<<std::endl;
87     rin->left = xin/scale_mult;
88     rin->top = yin/scale_mult;
89     rin->width = rout->width/scale_mult;
90     rin->height = rout->height/scale_mult;
91   }
92   */
93 
94 
95   VipsImage* build(std::vector<VipsImage*>& in, int first,
96       VipsImage* imap, VipsImage* omap,
97       unsigned int& level);
98 };
99 
100 
101 
102 template < OP_TEMPLATE_DEF >
103 class PerspectiveProc
104 {
105 public:
render(VipsRegion ** ireg,int n,int in_first,VipsRegion * imap,VipsRegion * omap,VipsRegion * oreg,OpParBase * par)106   void render(VipsRegion** ireg, int n, int in_first,
107       VipsRegion* imap, VipsRegion* omap,
108       VipsRegion* oreg, OpParBase* par)
109   {
110   }
111 };
112 
113 ProcessorBase* new_perspective();
114 }
115 
116 #endif
117 
118 
119