Revision 6316

View differences:

org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider.legend/src/main/java/org/gvsig/raster/gdal/provider/legend/RasterGdalGetColorInterpretation.java
112 112

  
113 113
        switch (gdalNameCI) {
114 114
        case "Undefined" :
115
            return ColorInterpretation.UNDEFINED_BAND;
115
            return ColorInterpretation.PALETTE_BAND;
116 116
        case "Gray" :
117 117
            return ColorInterpretation.GRAY_BAND;
118 118
        case "Palette" :
......
126 126
        case "Alpha" :
127 127
            return ColorInterpretation.ALPHA_BAND;
128 128
        case "Hue" :
129
            return ColorInterpretation.UNDEFINED_BAND;
129
            return ColorInterpretation.HUE_BAND;
130 130
        case "Saturation" :
131
            return ColorInterpretation.UNDEFINED_BAND;
131
            return ColorInterpretation.SATURATION_BAND;
132 132
        case "Lightness" :
133
            return ColorInterpretation.UNDEFINED_BAND;
133
            return ColorInterpretation.LIGHTNESS_BAND;
134 134
        case "Cyan" :
135
            return ColorInterpretation.UNDEFINED_BAND;
135
            return ColorInterpretation.CYAN_BAND;
136 136
        case "Magenta" :
137
            return ColorInterpretation.UNDEFINED_BAND;
137
            return ColorInterpretation.MAGENTA_BAND;
138 138
        case "Yellow" :
139
            return ColorInterpretation.UNDEFINED_BAND;
139
            return ColorInterpretation.YELLOW_BAND;
140 140
        case "Black" :
141
            return ColorInterpretation.UNDEFINED_BAND;
141
            return ColorInterpretation.BLACK_BAND;
142 142
        case "YCbCr_Y" :
143
            return ColorInterpretation.UNDEFINED_BAND;
143
            return ColorInterpretation.YCBCR_Y_BAND;
144 144
        case "YCbCr_Cb" :
145
            return ColorInterpretation.UNDEFINED_BAND;
145
            return ColorInterpretation.YCBCR_CB_BAND;
146 146
        case "YCbCr_Cr" :
147
            return ColorInterpretation.UNDEFINED_BAND;
147
            return ColorInterpretation.YCBCR_CR_BAND;
148 148
        default:
149 149
            return ColorInterpretation.UNDEFINED_BAND;
150 150
        }
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.gdal/org.gvsig.raster.gdal.provider.legend/src/main/java/org/gvsig/raster/gdal/provider/legend/RasterGdalGetColorTable.java
66 66

  
67 67
            ColorInterpretation colorInterpretation =(ColorInterpretation)rasterGdalProvider.
68 68
                invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null);
69
            for (int i = 0; i < gdalDataSet.getRasterCount(); i++) {
70
                if (ColorInterpretation.PALETTE_BAND.equals(colorInterpretation.get(i))){
71
                    // Bands begin in 1 instead of 0
72
                    int bandNumber = i + 1;
69
            for (int bandNumber = 1; bandNumber <= gdalDataSet.getRasterCount(); bandNumber++) {
70
                //Band in GDAL begins in 1, meanwhile we begin in 0
71
                int indexColorInterpretation=bandNumber-1;
72
                if (ColorInterpretation.PALETTE_BAND.equals(colorInterpretation.get(indexColorInterpretation))){
73 73
                    Band gdalBand=gdalDataSet.GetRasterBand(bandNumber);
74 74
                    org.gdal.gdal.ColorTable gdalBandColorTable = gdalBand.GetColorTable();
75 75
                    if (gdalBandColorTable!=null){
76 76
                        List<ColorTableClass> colorTableClasses=new ArrayList<ColorTableClass>();
77 77

  
78
                        for (int j=0;j<gdalBandColorTable.GetCount();j++){
79
                            String className=j+"";
80
                            double value=((byte)j);
78
                        for (int i=0;i<gdalBandColorTable.GetCount();i++){
79
                            String className=i+"";
80
                            double value=((byte)i);
81 81
                            double interpolation=50.0;
82
                            Color color=gdalBandColorTable.GetColorEntry(j);
82
                            Color color=gdalBandColorTable.GetColorEntry(i);
83 83
                            ColorTableClass colorTableClass = legendManager.createColorTableClass(className, value, interpolation, color);
84 84
                            colorTableClasses.add(colorTableClass);
85 85
                        }
......
89 89
                        //FIXME: De momento devolvemos el primero solo.
90 90
                        return colorTable;
91 91
                    }
92
                    else {
93
                        List<ColorTableClass> colorTableClasses=new ArrayList<ColorTableClass>();
94
                        double[] minMax=new double[2];
95
                        gdalBand.ComputeRasterMinMax(minMax);
96
                        Double increment=(minMax[1]-minMax[0])/256;
97

  
98
                        for (int i=0;i<255;i++){
99
                            String className=i+"";
100
                            double value=((minMax[0]+(i*increment)));
101
                            double interpolation=50.0;
102
                            int intARGB = ((i & 0xFF) << 24) | // alpha
103
                                ((i & 0xFF) << 16) | // red
104
                                ((i & 0xFF) << 8) | // green
105
                                ((i & 0xFF) << 0); // blue
106
                            Color color=new Color(intARGB);
107
                            ColorTableClass colorTableClass = legendManager.createColorTableClass(className, value, interpolation, color);
108
                            colorTableClasses.add(colorTableClass);
109
                        }
110
                        String colorTableName = rasterGdalProvider.getName() + "_color_table";
111
                        colorTable = legendManager.createColorTable(colorTableName,
112
                            colorTableClasses, true);
113
                        //FIXME: De momento devolvemos el primero solo.
114
                        return colorTable;
115
                    }
92 116
                }
93 117

  
94 118
            }

Also available in: Unified diff