Revision 8682 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.legend/org.gvsig.raster.lib.legend.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/rgbtohsl/RGBToHSLOperation.java

View differences:

RGBToHSLOperation.java
34 34
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException;
35 35
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
36 36
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
37
import org.gvsig.raster.lib.buffer.impl.exceptions.ProcessingOperationException;
37
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
38 38
import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation;
39 39
import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
40 40
import org.gvsig.raster.lib.legend.api.RasterLegendManager;
41 41
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
42 42
import org.gvsig.raster.lib.legend.impl.ColorManager;
43 43
import org.gvsig.raster.lib.legend.impl.RasterLegendManagerServices;
44
import org.gvsig.raster.lib.legend.spi.AbstractColoredOperation;
44 45
import org.gvsig.tools.locator.LocatorException;
45 46

  
46 47

  
......
48 49
 * @author fdiaz
49 50
 *
50 51
 */
51
public class RGBToHSLOperation extends AbstractOperation {
52
public class RGBToHSLOperation extends AbstractColoredOperation {
52 53

  
53
    static public String COLOR_INTERPRETATION_PARAM = "color_interpretation";
54
    static public String COPY_UNPROCESSED_BANDS_PARAM = "copy_unprocessed_bands";
55
    static public String OUTPUT_COLOR_INTERPRETATION_PARAM = "output_color_interpretation";
56

  
57
    private ColorInterpretation colorInterpretation;
58
    private boolean copyUnprocessedBands;
59
    private ColorInterpretation outputColorInterpretation;
60

  
61 54
    /**
62 55
     * @param factory
63 56
     *
......
68 61

  
69 62
    @Override
70 63
    public void preProcess() throws BufferOperationException {
64
        super.preProcess();
71 65
        BufferManager manager = BufferLocator.getBufferManager();
72 66
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
73 67

  
74
        colorInterpretation = (ColorInterpretation) this.parameters.getDynValue(COLOR_INTERPRETATION_PARAM);
75
        if (this.parameters.hasDynValue(COPY_UNPROCESSED_BANDS_PARAM)) {
76
            copyUnprocessedBands = (Boolean) this.parameters.getDynValue(COPY_UNPROCESSED_BANDS_PARAM);
77
        } else {
78
            copyUnprocessedBands = true;
79
        }
80

  
81 68
        try {
82 69
            if (!(colorInterpretation.isGray() || colorInterpretation.isRGB())) {
83 70
                throw new UnsupportedOperationException(
......
160 147

  
161 148
    @Override
162 149
    public void process() throws ProcessingOperationException {
150
        super.process();
163 151
        try {
164 152

  
165 153
            // List<Integer> bandsToProcess = new ArrayList<Integer>();
......
224 212

  
225 213
    @Override
226 214
    public void postProcess() throws BufferOperationException {
227
        // TODO Auto-generated method stub
228

  
215
        super.postProcess();
229 216
    }
230 217

  
231 218
    private void processRow(Object[] inputRows, List outputRows) {
......
238 225

  
239 226
            double[] convertedValues = colorManager.RGBtoHSL(0xFF & inputByteRows[0][i], 0xFF & inputByteRows[1][i], 0xFF & inputByteRows[2][i]);
240 227

  
241
            ((byte[])(outputRows.get(0)))[i] += (new Double(convertedValues[0]*255)).byteValue();
242
            ((byte[])(outputRows.get(1)))[i] += (new Double(convertedValues[1]*100)).byteValue();
243
            ((byte[])(outputRows.get(2)))[i] += (new Double(convertedValues[2]*100)).byteValue();
228
            ((byte[])(outputRows.get(0)))[i] += new Double((convertedValues[0]*255)/360.0 + 0.5).byteValue();
229
            ((byte[])(outputRows.get(1)))[i] += new Double(convertedValues[1]*255+0.5).byteValue();
230
            ((byte[])(outputRows.get(2)))[i] += new Double(convertedValues[2]*255+0.5).byteValue();
244 231
        }
245 232
    }
246 233
    /**

Also available in: Unified diff