Revision 4998
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/EcwFile.java | ||
---|---|---|
689 | 689 |
* @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int origBand, int destBand) |
690 | 690 |
*/ |
691 | 691 |
public Image updateImage(int width, int height, ICoordTrans rp, Image img, |
692 |
int origBand, int destBandFlag) { |
|
692 |
int origBand, int destBandFlag) throws SupersamplingNotSupportedException{
|
|
693 | 693 |
//TODO reproyectar para devolver el trozo de imagen pedida sobre ... |
694 | 694 |
// la proyecci?n de destino. |
695 | 695 |
int line = 0; |
696 | 696 |
boolean mustResize = false; |
697 | 697 |
Dimension fullSize = null; |
698 |
boolean trySupersampling = false; |
|
698 | 699 |
|
699 | 700 |
if (file == null) { |
700 | 701 |
return null; |
... | ... | |
772 | 773 |
|
773 | 774 |
for (int nChunk = 0; nChunk < frames.length; nChunk++) { |
774 | 775 |
ChunkFrame f = frames[nChunk]; |
775 |
|
|
776 |
if (bandCount != 3) { |
|
777 |
setFileView(file.numBands, bandlist, f); |
|
778 |
} else { |
|
779 |
setFileView(file.numBands, bandListTriband, f); |
|
776 |
|
|
777 |
try{ |
|
778 |
if (bandCount != 3) { |
|
779 |
setFileView(file.numBands, bandlist, f); |
|
780 |
} else { |
|
781 |
setFileView(file.numBands, bandListTriband, f); |
|
782 |
} |
|
783 |
}catch(JNCSInvalidSetViewException exc){ |
|
784 |
trySupersampling = true; |
|
780 | 785 |
} |
781 | 786 |
|
782 | 787 |
order = calcMaskAndShift(bandlist, mascara, shl, shr); |
... | ... | |
791 | 796 |
applyAlpha(ecwImage); |
792 | 797 |
|
793 | 798 |
if (frames[0].mustResize && !this.multifile) |
794 |
return resizeImage(fullSize, ecwImage); |
|
799 |
return resizeImageII(fullSize, ecwImage);
|
|
795 | 800 |
|
796 | 801 |
lastRefreshPercent = file.getPercentComplete(); |
797 | 802 |
|
... | ... | |
821 | 826 |
applyAlpha(img); |
822 | 827 |
|
823 | 828 |
if (frames[0].mustResize && (nUpdate == 3) && this.multifile) { |
824 |
return resizeImage(fullSize, img); |
|
829 |
return resizeImageII(fullSize, img);
|
|
825 | 830 |
} |
826 | 831 |
|
827 | 832 |
lastRefreshPercent = file.getPercentComplete(); |
... | ... | |
834 | 839 |
System.err.println("EcwFile JNCS Error en la l?nea " + line + "/" + |
835 | 840 |
height); |
836 | 841 |
System.err.println(e.getMessage()); |
837 |
e.printStackTrace(); |
|
838 | 842 |
} catch (java.lang.ArrayIndexOutOfBoundsException e) { //: |
839 | 843 |
bErrorOnOpen = true; |
840 |
System.err.println("EcwFile ArrayIndex Error en la l?nea " + line + |
|
841 |
"/" + height); |
|
844 |
System.err.println("EcwFile ArrayIndex Error en la l?nea " + line +"/" + height); |
|
842 | 845 |
System.err.println(e.getMessage()); |
843 |
e.printStackTrace(); |
|
844 | 846 |
} catch (Exception e) { |
845 | 847 |
bErrorOnOpen = true; |
846 | 848 |
errorMessage = e.getMessage(); |
847 | 849 |
System.err.println(errorMessage); |
848 |
e.printStackTrace(); |
|
850 |
if(trySupersampling) |
|
851 |
throw new SupersamplingNotSupportedException(); |
|
849 | 852 |
} |
850 | 853 |
|
851 | 854 |
return img; |
... | ... | |
864 | 867 |
double offsetX = Math.abs(currentViewX - ((int)currentViewX)); |
865 | 868 |
double offsetY = Math.abs(currentViewY - ((int)currentViewY)); |
866 | 869 |
|
867 |
int[] pixels = new int[w * h]; |
|
868 |
int posDst, xSrc, ySrc; |
|
869 |
double scaleW = (double)((double)image.getWidth(null) / (double)w); |
|
870 |
double scaleH = (double)((double)image.getHeight(null) / (double)h); |
|
870 |
int xSrc, ySrc; |
|
871 |
double scaleW = (double)((double)(image.getWidth(null) - 2) / (double)w); |
|
872 |
double scaleH = (double)((double)(image.getHeight(null) - 2) / (double)h); |
|
871 | 873 |
for (int y1 = 0; y1 < h; y1++){ |
872 |
ySrc = (int) ((y1 * scaleH)); |
|
874 |
ySrc = (int) ((y1 * scaleH) + offsetY);
|
|
873 | 875 |
for (int x1 = 0; x1 < w; x1++) { |
874 |
xSrc = (int) ((x1 * scaleW)); |
|
876 |
xSrc = (int) ((x1 * scaleW) + offsetX);
|
|
875 | 877 |
try { |
876 | 878 |
((BufferedImage) buffImg).setRGB(x1, y1, ((BufferedImage)image).getRGB(xSrc, ySrc)); |
877 | 879 |
} catch (java.lang.ArrayIndexOutOfBoundsException e) { |
... | ... | |
1023 | 1025 |
if ((ptMax.x - ptMin.x) < sz.width) { |
1024 | 1026 |
numCol = numRow = 1; |
1025 | 1027 |
frames = new ChunkFrame[numCol * numRow]; |
1026 |
f = frames[0] = new ChunkFrame(v, (int)Math.ceil(Math.abs(currentViewMaxX - currentViewMinX)), |
|
1027 |
(int)Math.ceil(Math.abs(currentViewMaxY - currentViewMinY))); |
|
1028 |
int nPixelsX = (int)Math.ceil(Math.abs(currentViewMaxX - currentViewMinX)); |
|
1029 |
int nPixelsY = (int)Math.ceil(Math.abs(currentViewMaxY - currentViewMinY)); |
|
1030 |
f = frames[0] = new ChunkFrame(v, nPixelsX + 1, nPixelsY + 1); |
|
1028 | 1031 |
|
1029 |
//System.out.println("Size=("+f.width+","+f.height+")"); |
|
1030 | 1032 |
f.pos = new Point(0, 0); |
1031 | 1033 |
f.mustResize = true; |
1032 |
f.v = new Extent(v); |
|
1034 |
//f.v = new Extent(v); |
|
1035 |
double pointEndWcX = v.minX() + (((nPixelsX + 1) * Math.abs(v.maxX() - v.minX())) / nPixelsX); |
|
1036 |
double pointEndWcY = v.minY() + (((nPixelsY + 1) * Math.abs(v.maxY() - v.minY())) / nPixelsY); |
|
1037 |
f.v = new Extent(v.minX(), v.minY(), pointEndWcX, pointEndWcY); |
|
1033 | 1038 |
} else { |
1034 | 1039 |
// Calcula cada chunk |
1035 | 1040 |
double stepx = ((double) ptMax.x - ptMin.x) / sz.getWidth(); |
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/MrSidFile.java | ||
---|---|---|
812 | 812 |
* @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int) |
813 | 813 |
*/ |
814 | 814 |
public Image updateImage(int width, int height, ICoordTrans rp, Image img, |
815 |
int origBand, int destBandFlag) { |
|
815 |
int origBand, int destBandFlag) throws SupersamplingNotSupportedException{
|
|
816 | 816 |
int line; |
817 | 817 |
int[] pRGBArray = null; |
818 | 818 |
Image mrSidImage = null; |
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GeoRasterFile.java | ||
---|---|---|
309 | 309 |
* @param img imagen |
310 | 310 |
* @param flags que bandas [ RED_BAND | GREEN_BAND | BLUE_BAND ] |
311 | 311 |
* @return img |
312 |
* @throws SupersamplingNotSupportedException |
|
312 | 313 |
*/ |
313 |
abstract public Image updateImage(int width, int height, ICoordTrans rp, Image img, int origBand, int destBand); |
|
314 |
abstract public Image updateImage(int width, int height, ICoordTrans rp, Image img, int origBand, int destBand)throws SupersamplingNotSupportedException;
|
|
314 | 315 |
|
315 | 316 |
public int getBandCount() { return bandCount; } |
316 | 317 |
|
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/SupersamplingNotSupportedException.java | ||
---|---|---|
1 |
package org.cresques.io; |
|
2 |
|
|
3 |
/** |
|
4 |
* Excepci?n que indica que un driver no soporta supersampling, es decir no se pueden |
|
5 |
* tomar muestras del contenido de un pixel en distintas posiciones. |
|
6 |
* |
|
7 |
* @author Nacho Brodin (brodin_ign@gva.es) |
|
8 |
*/ |
|
9 |
public class SupersamplingNotSupportedException extends Exception { |
|
10 |
/** |
|
11 |
* |
|
12 |
*/ |
|
13 |
public SupersamplingNotSupportedException() { |
|
14 |
super(); |
|
15 |
|
|
16 |
// TODO Auto-generated constructor stub |
|
17 |
} |
|
18 |
|
|
19 |
/** |
|
20 |
* DOCUMENT ME! |
|
21 |
* |
|
22 |
* @param message |
|
23 |
*/ |
|
24 |
public SupersamplingNotSupportedException(String message) { |
|
25 |
super(message); |
|
26 |
|
|
27 |
// TODO Auto-generated constructor stub |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* DOCUMENT ME! |
|
32 |
* |
|
33 |
* @param message |
|
34 |
* @param cause |
|
35 |
*/ |
|
36 |
public SupersamplingNotSupportedException(String message, Throwable cause) { |
|
37 |
super(message, cause); |
|
38 |
|
|
39 |
// TODO Auto-generated constructor stub |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* DOCUMENT ME! |
|
44 |
* |
|
45 |
* @param cause |
|
46 |
*/ |
|
47 |
public SupersamplingNotSupportedException(Throwable cause) { |
|
48 |
super(cause); |
|
49 |
|
|
50 |
// TODO Auto-generated constructor stub |
|
51 |
} |
|
52 |
} |
|
0 | 53 |
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GdalFile.java | ||
---|---|---|
305 | 305 |
GdalBuffer [] bands = {r,g,b}; |
306 | 306 |
for (int k=0; k<4; k++){ |
307 | 307 |
for (i=0, j = initOffset; i<currentViewWidth && j<r.getSize(); i++, j+=step){ |
308 |
//Truncamos el float perdiendo centimetros. Es necesario para visualizar |
|
309 | 308 |
if(k < 3) |
310 | 309 |
line[i][k] = (int)bands[0].buffFloat[(int) j]; |
311 | 310 |
else |
... | ... | |
823 | 822 |
/* (non-Javadoc) |
824 | 823 |
* @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int, int) |
825 | 824 |
*/ |
826 |
public Image updateImage(int width, int height, ICoordTrans rp, Image img, int origBand, int destBandFlag){ |
|
825 |
public Image updateImage(int width, int height, ICoordTrans rp, Image img, int origBand, int destBandFlag)throws SupersamplingNotSupportedException{
|
|
827 | 826 |
int line, pRGBArray[] = null; |
828 | 827 |
|
829 | 828 |
if(mustVerifySize()){ |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.cresques.px; |
25 | 25 |
|
26 |
import java.awt.Color; |
|
27 |
import java.awt.Component; |
|
28 |
import java.awt.Graphics2D; |
|
29 |
import java.awt.Image; |
|
30 |
import java.awt.geom.GeneralPath; |
|
31 |
import java.awt.geom.Point2D; |
|
32 |
import java.awt.image.BufferedImage; |
|
33 |
import java.awt.image.DataBuffer; |
|
34 |
import java.awt.image.ImageObserver; |
|
35 |
import java.util.ArrayList; |
|
36 |
import java.util.Date; |
|
37 |
import java.util.Vector; |
|
38 |
|
|
26 | 39 |
import org.cresques.cts.ICoordTrans; |
27 | 40 |
import org.cresques.cts.IProjection; |
28 |
|
|
29 | 41 |
import org.cresques.geo.Projected; |
30 | 42 |
import org.cresques.geo.ViewPortData; |
31 |
|
|
32 | 43 |
import org.cresques.io.EcwFile; |
33 | 44 |
import org.cresques.io.GdalFile; |
34 | 45 |
import org.cresques.io.GeoRasterFile; |
46 |
import org.cresques.io.SupersamplingNotSupportedException; |
|
35 | 47 |
import org.cresques.io.raster.RasterBuf; |
36 | 48 |
import org.cresques.io.raster.RasterFilterStack; |
37 | 49 |
import org.cresques.io.raster.RasterFilterStackManager; |
38 | 50 |
import org.cresques.io.raster.RasterStats; |
39 | 51 |
import org.cresques.io.raster.RasterToImageFilter; |
40 | 52 |
|
41 |
import java.awt.Color; |
|
42 |
import java.awt.Component; |
|
43 |
import java.awt.Graphics2D; |
|
44 |
import java.awt.Image; |
|
45 |
import java.awt.geom.GeneralPath; |
|
46 |
import java.awt.geom.Point2D; |
|
47 |
import java.awt.image.BufferedImage; |
|
48 |
import java.awt.image.DataBuffer; |
|
49 |
import java.awt.image.ImageObserver; |
|
50 | 53 |
|
51 |
import java.util.ArrayList; |
|
52 |
import java.util.Date; |
|
53 |
import java.util.Vector; |
|
54 |
|
|
55 |
|
|
56 | 54 |
/** |
57 | 55 |
* |
58 | 56 |
* @author Luis W. Sevilla (sevilla_lui@gva.es) |
... | ... | |
828 | 826 |
System.out.println("Dibujando PxRaster: " + |
829 | 827 |
((t2 - t1) / 1000D) + ", secs."); |
830 | 828 |
} else if ((geoFile != null) ) { // Una solo fichero |
831 |
geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage(wImg, hImg, rp, null, 0, 0);
|
|
832 |
|
|
829 |
geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage(wImg, hImg, rp, null, 0, 0);
|
|
830 |
|
|
833 | 831 |
filterStack.setInitRasterBuf(geoImage); |
834 | 832 |
|
835 | 833 |
geoImage = renderizeRaster(geoImage, vp, v); |
... | ... | |
842 | 840 |
} else { // no cargada |
843 | 841 |
System.err.println("Dibujando PxRaster: Foto no cargada."); |
844 | 842 |
} |
845 |
} catch (Exception e) { |
|
843 |
}catch (SupersamplingNotSupportedException e) { |
|
844 |
System.err.println("Supersampling not supported"); |
|
845 |
return; |
|
846 |
}catch (Exception e) { |
|
846 | 847 |
e.printStackTrace(); |
847 | 848 |
} |
848 | 849 |
|
Also available in: Unified diff