svn-gvsig-desktop / tags / v1_1_Build_1008 / libraries / libCq_CMS_praster / src / org / cresques / filter / bands / RasterFloatToImageFilter.java @ 12520
History | View | Annotate | Download (2.75 KB)
1 |
package org.cresques.filter.bands; |
---|---|
2 |
|
3 |
public class RasterFloatToImageFilter extends RasterToImageFilter { |
4 |
|
5 |
private float[] px = {0, 0, 0, 255}; |
6 |
|
7 |
/**
|
8 |
* Constructor
|
9 |
*
|
10 |
*/
|
11 |
public RasterFloatToImageFilter() {
|
12 |
} |
13 |
|
14 |
/* (non-Javadoc)
|
15 |
* @see org.cresques.io.raster.IRasterFilter#pre()
|
16 |
*/
|
17 |
public void pre() { |
18 |
super.pre();
|
19 |
} |
20 |
|
21 |
/* (non-Javadoc)
|
22 |
* @see org.cresques.px.PxRaster.RasterFilter#process(int, int)
|
23 |
*/
|
24 |
public void process(int col, int line) { |
25 |
raster.getElemFloat(line, col, px); |
26 |
rgb = (alpha & ((((int)255) & 0xff) << 24)) | ((Math.round(px[0]) & 0xff) << 16) | |
27 |
((Math.round(px[1]) & 0xff) << 8) | (Math.round(px[2]) & 0xff); |
28 |
/*rgb = (alpha & ((Math.round(px[3]) & 0xff) << 24)) | ((Math.round(px[0]) & 0xff) << 16) |
|
29 |
((Math.round(px[1]) & 0xff) << 8) | (Math.round(px[2]) & 0xff);*/
|
30 |
|
31 |
image.setRGB(col, line, rgb); |
32 |
} |
33 |
|
34 |
public void processSuperSampling(int col, int line){ |
35 |
raster.getElemFloat(line, col, px); |
36 |
rgb = (alpha & ((((int)255) & 0xff) << 24)) | ((Math.round(px[0]) & 0xff) << 16) | |
37 |
((Math.round(px[1]) & 0xff) << 8) | (Math.round(px[2]) & 0xff); |
38 |
/*rgb = (alpha & ((Math.round(px[3]) & 0xff) << 24)) | ((Math.round(px[0]) & 0xff) << 16) |
|
39 |
((Math.round(px[1]) & 0xff) << 8) | (Math.round(px[2]) & 0xff);*/
|
40 |
|
41 |
for(int j = col; j < raster.getWidth() && j < (col + stepX[contX + 1]); j++) |
42 |
for(int i = line; i < raster.getHeight() && i < (line + stepY[contY + 1]); i++) |
43 |
image.setRGB(j, i, rgb); |
44 |
} |
45 |
|
46 |
/* (non-Javadoc)
|
47 |
* @see org.cresques.io.raster.IRasterFilter#getResult(java.lang.String)
|
48 |
*/
|
49 |
public Object getResult(String name) { |
50 |
return super.getResult(name); |
51 |
} |
52 |
|
53 |
/* (non-Javadoc)
|
54 |
* @see org.cresques.px.PxRaster.RasterFilter#processLines(int)
|
55 |
*/
|
56 |
public void processLine(int y) { |
57 |
for (int x = 0; x < width; x++) { |
58 |
float[][] line = raster.getLineFloat(y); |
59 |
rgb = (alpha & ((Math.round(px[3]) & 0xff) << 24)) | |
60 |
((Math.round(line[x][0]) & 0xff) << 16) | ((Math.round(line[x][1]) & 0xff) << 8) | |
61 |
(Math.round(line[x][2]) & 0xff); |
62 |
|
63 |
image.setRGB(x, y, rgb); |
64 |
} |
65 |
} |
66 |
|
67 |
/* (non-Javadoc)
|
68 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
|
69 |
*/
|
70 |
public int getInRasterDataType() { |
71 |
return super.getInRasterDataType(); |
72 |
} |
73 |
|
74 |
/* (non-Javadoc)
|
75 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
|
76 |
*/
|
77 |
public int getOutRasterDataType() { |
78 |
return super.getOutRasterDataType(); |
79 |
} |
80 |
|
81 |
/* (non-Javadoc)
|
82 |
* @see org.cresques.io.raster.IRasterFilter#post()
|
83 |
*/
|
84 |
public void post() { |
85 |
super.post();
|
86 |
} |
87 |
|
88 |
} |