Revision 11453 trunk/libraries/libRaster/src/org/gvsig/raster/buffer/RasterMemoryBuffer.java
RasterMemoryBuffer.java | ||
---|---|---|
1093 | 1093 |
return null; |
1094 | 1094 |
} |
1095 | 1095 |
|
1096 |
/* |
|
1097 |
* (non-Javadoc) |
|
1098 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterNearestNeighbourInterpolation(int, int, int[]) |
|
1099 |
*/ |
|
1100 |
public RasterBuffer adjustRasterNearestNeighbourInterpolation(int w, int h, int[] bands){ |
|
1101 |
double stepX = (double)w / (double)width; |
|
1102 |
double stepY = (double)h / (double)height; |
|
1103 |
RasterBuffer rasterBuf = new RasterMemoryBuffer(getDataType(), w, h, getBandCount(), true); |
|
1104 |
|
|
1105 |
//Si bands == null las bandas a copiar son todas las de la imagen |
|
1106 |
if(bands == null){ |
|
1107 |
bands = new int[rasterBuf.getBandCount()]; |
|
1108 |
for(int iBand = 0; iBand < rasterBuf.getBandCount(); iBand ++) |
|
1109 |
bands[iBand] = iBand; |
|
1110 |
} |
|
1111 |
|
|
1112 |
switch (dataType) { |
|
1113 |
case RasterBuffer.TYPE_IMAGE: |
|
1114 |
|
|
1115 |
case RasterBuffer.TYPE_BYTE: |
|
1116 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1117 |
if(w <= width){ //submuestreo |
|
1118 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1119 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1120 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemByte(iRow, iCol, iBand)); |
|
1121 |
}else{ //supermuestreo |
|
1122 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1123 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1124 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemByte((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1125 |
} |
|
1126 |
} |
|
1127 |
break; |
|
1128 |
case RasterBuffer.TYPE_DOUBLE: |
|
1129 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1130 |
if(w <= width){ //submuestreo |
|
1131 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1132 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1133 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemDouble(iRow, iCol, iBand)); |
|
1134 |
}else{ //supermuestreo |
|
1135 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1136 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1137 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemDouble((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1138 |
} |
|
1139 |
} |
|
1140 |
break; |
|
1141 |
case RasterBuffer.TYPE_FLOAT: |
|
1142 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1143 |
if(w <= width){ //submuestreo |
|
1144 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1145 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1146 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemFloat(iRow, iCol, iBand)); |
|
1147 |
}else{ //supermuestreo |
|
1148 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1149 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1150 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemFloat((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1151 |
} |
|
1152 |
} |
|
1153 |
break; |
|
1154 |
case RasterBuffer.TYPE_INT: |
|
1155 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1156 |
if(w <= width){ //submuestreo |
|
1157 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1158 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1159 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemInt(iRow, iCol, iBand)); |
|
1160 |
}else{ //supermuestreo |
|
1161 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1162 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1163 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemInt((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1164 |
} |
|
1165 |
} |
|
1166 |
break; |
|
1167 |
case RasterBuffer.TYPE_USHORT: |
|
1168 |
case RasterBuffer.TYPE_SHORT: |
|
1169 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1170 |
if(w <= width){ //submuestreo |
|
1171 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1172 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1173 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemShort(iRow, iCol, iBand)); |
|
1174 |
}else{ //supermuestreo |
|
1175 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1176 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1177 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemShort((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1178 |
} |
|
1179 |
} |
|
1180 |
break; |
|
1181 |
} |
|
1182 |
return rasterBuf; |
|
1183 |
} |
|
1184 |
|
|
1185 |
/* |
|
1186 |
* (non-Javadoc) |
|
1187 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterBilinearInterpolation(int, int, int[]) |
|
1188 |
*/ |
|
1189 |
public RasterBuffer adjustRasterBilinearInterpolation(int w, int h, int[] bands) { |
|
1190 |
return null; |
|
1191 |
} |
|
1192 |
|
|
1193 |
/* |
|
1194 |
* (non-Javadoc) |
|
1195 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterInverseDistanceInterpolation(int, int, int[]) |
|
1196 |
*/ |
|
1197 |
public RasterBuffer adjustRasterInverseDistanceInterpolation(int w, int h, int[] bands) { |
|
1198 |
return null; |
|
1199 |
} |
|
1200 |
|
|
1201 |
/* |
|
1202 |
* (non-Javadoc) |
|
1203 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterBicubicSplineInterpolation(int, int, int[]) |
|
1204 |
*/ |
|
1205 |
public RasterBuffer adjustRasterBicubicSplineInterpolation(int w, int h, int[] bands) { |
|
1206 |
return null; |
|
1207 |
} |
|
1208 |
|
|
1209 |
/* |
|
1210 |
* (non-Javadoc) |
|
1211 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterBSplineInterpolation(int, int, int[]) |
|
1212 |
*/ |
|
1213 |
public RasterBuffer adjustRasterBSplineInterpolation(int w, int h, int[] bands) { |
|
1214 |
return null; |
|
1215 |
} |
|
1216 |
|
|
1217 | 1096 |
private ByteBand byteNotValid; |
1218 | 1097 |
private ShortBand shortNotValid; |
1219 | 1098 |
private IntBand intNotValid; |
... | ... | |
1224 | 1103 |
* (non-Javadoc) |
1225 | 1104 |
* @see org.gvsig.fmap.driver.IBuffer#assignBandToNotValid(int) |
1226 | 1105 |
*/ |
1227 |
public void assignBandToNotValid(int iBand){ |
|
1106 |
public void assignBandToNotValid(int iBand) {
|
|
1228 | 1107 |
switch(getDataType()){ |
1229 |
case IBuffer.TYPE_BYTE: if(byteNotValid == null){ |
|
1108 |
case IBuffer.TYPE_BYTE: if(byteNotValid == null) {
|
|
1230 | 1109 |
byteNotValid = new ByteBand(getHeight(), getWidth(), true); |
1231 | 1110 |
for(int i = 0 ; i < getWidth(); i ++) |
1232 | 1111 |
for(int j = 0 ; j < getHeight(); j ++) |
... | ... | |
1234 | 1113 |
} |
1235 | 1114 |
byteBuf[iBand] = byteNotValid; |
1236 | 1115 |
break; |
1237 |
case IBuffer.TYPE_SHORT: if(shortNotValid == null){ |
|
1116 |
case IBuffer.TYPE_SHORT: if(shortNotValid == null) {
|
|
1238 | 1117 |
shortNotValid = new ShortBand(getHeight(), getWidth(), true); |
1239 | 1118 |
for(int i = 0 ; i < getWidth(); i ++) |
1240 | 1119 |
for(int j = 0 ; j < getHeight(); j ++) |
... | ... | |
1242 | 1121 |
} |
1243 | 1122 |
shortBuf[iBand] = shortNotValid; |
1244 | 1123 |
break; |
1245 |
case IBuffer.TYPE_INT: if(intNotValid == null){ |
|
1124 |
case IBuffer.TYPE_INT: if(intNotValid == null) {
|
|
1246 | 1125 |
intNotValid = new IntBand(getHeight(), getWidth(), true); |
1247 | 1126 |
for(int i = 0 ; i < getWidth(); i ++) |
1248 | 1127 |
for(int j = 0 ; j < getHeight(); j ++) |
... | ... | |
1250 | 1129 |
} |
1251 | 1130 |
intBuf[iBand] = intNotValid; |
1252 | 1131 |
break; |
1253 |
case IBuffer.TYPE_FLOAT: if(floatNotValid == null){ |
|
1132 |
case IBuffer.TYPE_FLOAT: if(floatNotValid == null) {
|
|
1254 | 1133 |
floatNotValid = new FloatBand(getHeight(), getWidth(), true); |
1255 | 1134 |
for(int i = 0 ; i < getWidth(); i ++) |
1256 | 1135 |
for(int j = 0 ; j < getHeight(); j ++) |
... | ... | |
1258 | 1137 |
} |
1259 | 1138 |
floatBuf[iBand] = floatNotValid; |
1260 | 1139 |
break; |
1261 |
case IBuffer.TYPE_DOUBLE: if(doubleNotValid == null){ |
|
1140 |
case IBuffer.TYPE_DOUBLE: if(doubleNotValid == null) {
|
|
1262 | 1141 |
doubleNotValid = new DoubleBand(getHeight(), getWidth(), true); |
1263 | 1142 |
for(int i = 0 ; i < getWidth(); i ++) |
1264 | 1143 |
for(int j = 0 ; j < getHeight(); j ++) |
Also available in: Unified diff