Revision 11819 trunk/libraries/libRaster/src/org/gvsig/raster/grid/render/ImageDrawer.java
ImageDrawer.java | ||
---|---|---|
78 | 78 |
//Dibujado de raster de 1 o 2 bandas. |
79 | 79 |
//adaptBufferToRender(replicateBand, renderBands); |
80 | 80 |
|
81 |
//if(rasterBuf.getDataType() != IBuffer.TYPE_BYTE)
|
|
82 |
//rasterBuf = convertToByte(rasterBuf);
|
|
81 |
if(rasterBuf.getDataType() != IBuffer.TYPE_BYTE) |
|
82 |
rasterBuf = convertToByte(rasterBuf); |
|
83 | 83 |
|
84 | 84 |
//Asigna la banda de transparencia si existe esta. |
85 | 85 |
assignTransparencyBand(renderBands); |
... | ... | |
272 | 272 |
|
273 | 273 |
private IBuffer convertToByte(IBuffer buf) { |
274 | 274 |
IBuffer b = RasterBuffer.getBuffer(IBuffer.TYPE_BYTE, buf.getWidth(), buf.getHeight(), buf.getBandCount(), true); |
275 |
for (int nBand = 0; nBand < buf.getBandCount(); nBand++) |
|
276 |
for (int row = 0; row < buf.getHeight(); row++) |
|
277 |
for (int col = 0; col < buf.getWidth(); col++) |
|
278 |
b.setElem(row, col, nBand, (byte)(buf.getElemShort(row, col, nBand) & 0xffff)); |
|
275 |
if(buf.getDataType() == IBuffer.TYPE_SHORT) { |
|
276 |
for (int nBand = 0; nBand < buf.getBandCount(); nBand++) |
|
277 |
for (int row = 0; row < buf.getHeight(); row++) |
|
278 |
for (int col = 0; col < buf.getWidth(); col++) |
|
279 |
b.setElem(row, col, nBand, (byte)(buf.getElemShort(row, col, nBand) & 0xffff)); |
|
280 |
} |
|
281 |
if(buf.getDataType() == IBuffer.TYPE_INT) { |
|
282 |
for (int nBand = 0; nBand < buf.getBandCount(); nBand++) |
|
283 |
for (int row = 0; row < buf.getHeight(); row++) |
|
284 |
for (int col = 0; col < buf.getWidth(); col++) |
|
285 |
b.setElem(row, col, nBand, (byte)(buf.getElemInt(row, col, nBand) & 0xffff)); |
|
286 |
} |
|
287 |
if(buf.getDataType() == IBuffer.TYPE_FLOAT) { |
|
288 |
for (int nBand = 0; nBand < buf.getBandCount(); nBand++) |
|
289 |
for (int row = 0; row < buf.getHeight(); row++) |
|
290 |
for (int col = 0; col < buf.getWidth(); col++) |
|
291 |
b.setElem(row, col, nBand, (byte)(Math.round(buf.getElemFloat(row, col, nBand)) & 0xffff)); |
|
292 |
} |
|
293 |
if(buf.getDataType() == IBuffer.TYPE_DOUBLE) { |
|
294 |
for (int nBand = 0; nBand < buf.getBandCount(); nBand++) |
|
295 |
for (int row = 0; row < buf.getHeight(); row++) |
|
296 |
for (int col = 0; col < buf.getWidth(); col++) |
|
297 |
b.setElem(row, col, nBand, (byte)(Math.round(buf.getElemDouble(row, col, nBand)) & 0xffff)); |
|
298 |
} |
|
279 | 299 |
return b; |
280 | 300 |
} |
281 | 301 |
|
Also available in: Unified diff