Revision 4377 trunk/libraries/libCq CMS for java.old/src/org/cresques/io/raster/TransparencyShortFilter.java

View differences:

TransparencyShortFilter.java
50 50
    }
51 51

  
52 52
    /**
53
     * Para un vector de rangos de una banda concreta, si el punto pasado como par?metro
54
     * en la banda concreta est? en el rango especificado se asigna al valor de transparencia
55
     * por defecto.
56
     * @param range
57
     * @param banda
58
     * @param px
53
     * Asigna al pixel pasado como par?metro como transparente con 
54
     * el color de transparencia que est? seleccionado
55
     * @param px Pixel a asignarle transparencia
59 56
     */
60
    private void processRange(int[][] range, int banda, int[] px) {
61
        for (int i = 0; i < range.length; i++) {
62
            if (((px[banda] >= range[i][0]) && (px[banda] <= range[i][1]))) {
63
                px[3] = this.alpha;
64
                px[0] = this.transparencyColorRed;
65
                px[1] = this.transparencyColorGreen;
66
                px[2] = this.transparencyColorBlue;
67
            }
68
        }
57
    private void setPixelTransparent(int[] px){
58
		px[3] = this.alpha;
59
        px[0] = this.transparencyColorRed;
60
        px[1] = this.transparencyColorGreen;
61
        px[2] = this.transparencyColorBlue;	
69 62
    }
63
    
64
    /**     
65
     * @param range rango
66
     * @param banda banda
67
     * @param px    pixel
68
     */
69
    private void processRange(int[] px) {
70
    	for (int i = 0; i < rangesList.size(); i++) {
71
    		TransparencyRange tr = ((TransparencyRange)rangesList.get(i));
70 72

  
73
    		if(tr.isAnd()){
74
    			if(tr.getRed() != null)
75
    				if (px[0] < tr.getRed()[0] || px[0] > tr.getRed()[1])
76
    					continue;
77
    			if(tr.getGreen() != null)
78
    				if (px[1] < tr.getGreen()[0] || px[1] > tr.getGreen()[1])
79
    					continue;
80
    			if(tr.getBlue() != null)
81
    				if (px[2] < tr.getBlue()[0] || px[2] > tr.getBlue()[1])
82
    					continue;
83
    			if(tr.getRed() != null || tr.getGreen() != null || tr.getBlue() != null)
84
    				setPixelTransparent(px);
85
    			
86
    		}else{
87
    			if(tr.getRed() != null){
88
    				if (px[0] >= tr.getRed()[0] && px[0] <= tr.getRed()[1]){
89
    					setPixelTransparent(px);
90
    					continue;
91
    				}
92
    			}
93
    			if(tr.getGreen() != null){
94
    				if (px[1] >= tr.getGreen()[0] && px[1] <= tr.getGreen()[1]){
95
    					setPixelTransparent(px);
96
    					continue;
97
    				}
98
    			}
99
    			if(tr.getBlue() != null){
100
    				if (px[2] >= tr.getBlue()[0] && px[2] <= tr.getBlue()[1]){
101
    					setPixelTransparent(px);
102
    					continue;
103
    				}
104
    			}
105
    		}
106
    	}
107
    	
108
    }
109

  
71 110
    /* (non-Javadoc)
72 111
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
73 112
     */
74 113
    public void process(int x, int y) {
75 114
        raster.getElemInt(x, y, px);
76

  
77
        if (rangesR != null) {
78
            processRange(rangesR, 0, px);
79
        }
80

  
81
        if (rangesG != null) {
82
            processRange(rangesG, 1, px);
83
        }
84

  
85
        if (rangesB != null) {
86
            processRange(rangesB, 2, px);
87
        }
88

  
115
        processRange(px);
89 116
        raster.setElemInt(x, y, px);
90 117
    }
91 118

  

Also available in: Unified diff