Revision 4006 branches/v05/libraries/libCq CMS for java.old/src/org/cresques/io/GdalFile.java
GdalFile.java | ||
---|---|---|
57 | 57 |
class GdalNative extends Gdal { |
58 | 58 |
static boolean WITH_OVERVIEWS = true; |
59 | 59 |
private String ext = ""; |
60 |
private String shortName = ""; |
|
60 | 61 |
|
61 | 62 |
// Polilinea con extent |
62 | 63 |
public class Contour extends Vector { |
... | ... | |
130 | 131 |
esq.add(new Point2D.Double(width,height)); |
131 | 132 |
} |
132 | 133 |
setDataType(this.getRasterBand(1).getRasterDataType()); |
134 |
shortName = getDriverShortName(); |
|
133 | 135 |
} |
134 | 136 |
|
135 | 137 |
public void setAlpha(int a) { alpha = a; } |
... | ... | |
214 | 216 |
if (this.getRasterCount() > 1) { |
215 | 217 |
bandG = getRasterBand(gBandNr); |
216 | 218 |
bandB = getRasterBand(bBandNr); |
217 |
if(this.getRasterCount() >= 4 && ext.equals("png"))
|
|
219 |
if(this.getRasterCount() == 4 && shortName.equals("PNG"))
|
|
218 | 220 |
bandA = getRasterBand(aBandNr); |
219 | 221 |
} |
220 | 222 |
if (currentOverview > 0) { |
... | ... | |
222 | 224 |
if (this.getRasterCount() > 1) { |
223 | 225 |
bandG = bandG.getOverview(currentOverview); |
224 | 226 |
bandB = bandB.getOverview(currentOverview); |
225 |
if(this.getRasterCount() >= 4 && ext.equals("png"))
|
|
227 |
if(this.getRasterCount() == 4 && shortName.equals("PNG"))
|
|
226 | 228 |
bandA = bandA.getOverview(currentOverview); |
227 | 229 |
} |
228 | 230 |
} |
... | ... | |
331 | 333 |
b = new GdalBuffer(); |
332 | 334 |
b.buffByte = p.buffBPalette; |
333 | 335 |
}else{ |
334 |
r = bandR.readRaster(x, y, w, 1, w, 1, dataType); |
|
335 |
if (bandG != null) |
|
336 |
g = bandG.readRaster(x, y, w, 1, w, 1, dataType); |
|
337 |
if (bandB != null) |
|
338 |
b = bandB.readRaster(x, y, w, 1, w, 1, dataType); |
|
339 |
if(getRasterCount() >= 4 && ext.equals("png")) |
|
340 |
a = bandA.readRaster(x, y, w, 1, w, 1, GDT_Byte); |
|
341 |
else{ |
|
342 |
a.buffByte = new byte[w]; |
|
343 |
for (int i = 0;i < w;i++) |
|
344 |
a.buffByte[i] = (byte)255; |
|
345 |
} |
|
336 |
if(getRasterCount() == 4 && shortName.equals("PNG")){ |
|
337 |
a = bandA.readRaster(x, y, w, 1, w, 1, GDT_Byte); |
|
338 |
r = bandR.readRaster(x, y, w, 1, w, 1, dataType); |
|
339 |
if (bandG != null) |
|
340 |
g = bandG.readRaster(x, y, w, 1, w, 1, dataType); |
|
341 |
if (bandB != null) |
|
342 |
b = bandB.readRaster(x, y, w, 1, w, 1, dataType); |
|
343 |
for (int i = 0;i < w;i++){ |
|
344 |
if(a.buffByte[i] == 0){ |
|
345 |
r.buffByte[i] = (byte)255; |
|
346 |
g.buffByte[i] = (byte)255; |
|
347 |
b.buffByte[i] = (byte)255; |
|
348 |
} |
|
349 |
} |
|
350 |
|
|
351 |
}else{ |
|
352 |
r = bandR.readRaster(x, y, w, 1, w, 1, dataType); |
|
353 |
if (bandG != null) |
|
354 |
g = bandG.readRaster(x, y, w, 1, w, 1, dataType); |
|
355 |
if (bandB != null) |
|
356 |
b = bandB.readRaster(x, y, w, 1, w, 1, dataType); |
|
357 |
a.buffByte = new byte[w]; |
|
358 |
for (int i = 0;i < w;i++) |
|
359 |
a.buffByte[i] = (byte)255; |
|
360 |
} |
|
346 | 361 |
} |
347 | 362 |
|
348 | 363 |
lastReadLine += step; |
... | ... | |
415 | 430 |
b = new GdalBuffer(); |
416 | 431 |
b.buffByte = p.buffBPalette; |
417 | 432 |
}else{ |
418 |
r = bandR.readRaster(x, y, w, h, w, h, GDT_Byte); |
|
419 |
g = bandG.readRaster(x, y, w, h, w, h, GDT_Byte); |
|
420 |
b = bandB.readRaster(x, y, w, h, w, h, GDT_Byte); |
|
421 |
if(getRasterCount() >= 4 && ext.equals("png")) |
|
422 |
a = bandA.readRaster(x, y, w, h, w, h, GDT_Byte); |
|
423 |
else{ |
|
424 |
a.buffByte = new byte[w * h]; |
|
425 |
for (int i = 0;i < w;i++) |
|
426 |
a.buffByte[i] = (byte)255; |
|
427 |
} |
|
433 |
if(getRasterCount() == 4 && shortName.equals("PNG")){ |
|
434 |
a = bandA.readRaster(x, y, w, h, w, h, GDT_Byte); |
|
435 |
r = bandR.readRaster(x, y, w, h, w, h, dataType); |
|
436 |
if (bandG != null) |
|
437 |
g = bandG.readRaster(x, y, w, h, w, h, dataType); |
|
438 |
if (bandB != null) |
|
439 |
b = bandB.readRaster(x, y, w, h, w, h, dataType); |
|
440 |
for (int i = 0;i < w*h;i++){ |
|
441 |
if(a.buffByte[i] == 0){ |
|
442 |
r.buffByte[i] = (byte)255; |
|
443 |
g.buffByte[i] = (byte)255; |
|
444 |
b.buffByte[i] = (byte)255; |
|
445 |
} |
|
446 |
} |
|
447 |
}else{ |
|
448 |
r = bandR.readRaster(x, y, w, h, w, h, dataType); |
|
449 |
if (bandG != null) |
|
450 |
g = bandG.readRaster(x, y, w, h, w, h, dataType); |
|
451 |
if (bandB != null) |
|
452 |
b = bandB.readRaster(x, y, w, h, w, h, dataType); |
|
453 |
a.buffByte = new byte[w]; |
|
454 |
for (int i = 0;i < w*h;i++) |
|
455 |
a.buffByte[i] = (byte)255; |
|
456 |
} |
|
428 | 457 |
} |
429 | 458 |
lastReadLine += ((double)bandH)*step; |
430 | 459 |
|
Also available in: Unified diff