Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / grid / filter / band / RGBToCMYKFilter.java @ 2438

History | View | Annotate | Download (3.26 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.raster.impl.grid.filter.band;
23

    
24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.fmap.dal.coverage.datastruct.Params;
26
import org.gvsig.fmap.dal.coverage.exception.FilterAddException;
27
import org.gvsig.fmap.dal.coverage.grid.filter.BaseRasterFilter;
28
import org.gvsig.raster.impl.store.ParamsImpl;
29
import org.gvsig.raster.util.DefaultColorConversion;
30
/**
31
 * <P>
32
 * Clase base para los filtros de conversi?n de RGB a CMYK. La entrada ser? 
33
 * siempre un raster de 3 bandas que ser?n tomadas como RGB.
34
 * </P>
35
 *
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 */
38
public class RGBToCMYKFilter extends BaseRasterFilter {
39
        public static String[]            names            = new String[] { "rgbtocmyk" };
40
        protected DefaultColorConversion  colorConversion  = null;
41
        protected int                     out              = Buffer.TYPE_BYTE;
42
        protected int                     redBandNumber       = -1;
43
        protected int                     greenBandNumber     = -1;
44
        protected int                     blueBandNumber      = -1;
45

    
46
        /**
47
         * Constructor
48
         */
49
        public RGBToCMYKFilter() {
50
                super();
51
                setName(names[0]);
52
        }
53

    
54
        public void pre() throws FilterAddException {
55
                super.pre();
56
                out = ((Integer) params.get("outputType")).intValue();
57
                
58
                //A este filtro ya llega una imagen RGB con el orden de las bandas correcto 
59
                //ColorInterpretation colorInterpretation = getColorInterpretation();
60
                redBandNumber = 0;//colorInterpretation.getBand(ColorInterpretation.RED_BAND);
61
                greenBandNumber = 1;//colorInterpretation.getBand(ColorInterpretation.GREEN_BAND);
62
                blueBandNumber = 2;//colorInterpretation.getBand(ColorInterpretation.BLUE_BAND);
63
                
64
                if(out == Buffer.TYPE_BYTE)
65
                        createARGBBufferResult();
66
                else {
67
                        createBufferResult(out, 4);
68
                }
69
                        
70
                if(colorConversion == null)
71
                        colorConversion = new DefaultColorConversion();
72
        }
73
        
74
        public String getGroup() {
75
                return "colores";
76
        }
77

    
78
        public String[] getNames() {
79
                return names;
80
        }
81

    
82
        public Params getUIParams(String nameFilter) {
83
                Params params = new ParamsImpl();
84
                params.setParam("outputType",
85
                                new Integer(0),
86
                                Params.CHOICE,
87
                                new String[]{ "Byte", "Double"});
88
                return params;
89
        }
90

    
91
        public void post() {
92
        
93
        }
94

    
95
        public void process(int x, int y) {
96
        }
97

    
98
        public int getOutRasterDataType() {
99
                return Buffer.TYPE_BYTE;
100
        }
101

    
102
        public boolean isVisible() {
103
                return true;
104
        }
105

    
106
        public int getInRasterDataType() {
107
                return Buffer.TYPE_BYTE;
108
        }
109
}