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 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <fcntl.h>
33 
34 #include "../base/new_operation.hh"
35 #include "subtr_image.hh"
36 
37 
SubtrImgPar()38 PF::SubtrImgPar::SubtrImgPar():
39 OpParBase(),
40 blendFactor("blendFactor",this,0.5f)
41 {
42   subtrimg_algo = PF::new_subtrimg_algo();
43 
44   set_type("subtrimg" );
45   set_default_name( _("Subtract Image") );
46 }
47 
build(std::vector<VipsImage * > & in,int first,VipsImage * imap,VipsImage * omap,unsigned int & level)48 VipsImage* PF::SubtrImgPar::build(std::vector<VipsImage*>& in, int first,
49     VipsImage* imap, VipsImage* omap,
50     unsigned int& level)
51 {
52   if( (in.size()<2) || (in[0]==NULL)  || (in[1]==NULL) )
53     return NULL;
54 //  VipsImage* srcimg = in[0];
55 
56   std::vector<VipsImage*> in2;
57 
58   SubtrImgAlgoPar* subtr_img_par = dynamic_cast<SubtrImgAlgoPar*>( subtrimg_algo->get_par() );
59 
60   subtr_img_par->set_blendFactor( get_blendFactor() );
61 
62   subtr_img_par->set_image_hints( in[0] );
63   subtr_img_par->set_format( get_format() );
64   in2.clear();
65   in2.push_back( in[0] );
66   in2.push_back( in[1] );
67   VipsImage* subtrimg = subtr_img_par->build( in2, 0, NULL, NULL, level );
68 
69   set_image_hints( subtrimg );
70 
71   return subtrimg;
72 
73 }
74