svn-gvsig-desktop / tags / v1_1_Build_1001 / libraries / libCq_CMS_praster / src / org / cresques / filter / bands / RasterByteToImageFilter.java @ 11984
History | View | Annotate | Download (3.38 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.filter.bands; |
25 |
|
26 |
import java.awt.image.BufferedImage; |
27 |
|
28 |
import org.cresques.filter.RasterFilter; |
29 |
import org.cresques.io.data.RasterBuf; |
30 |
|
31 |
|
32 |
/**
|
33 |
* Convierte los elementos short de un RasterBuf a un pixel de un image.
|
34 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
35 |
*/
|
36 |
public class RasterByteToImageFilter extends RasterToImageFilter { |
37 |
private byte[] px = new byte[4]; |
38 |
|
39 |
/**
|
40 |
* Constructor
|
41 |
*
|
42 |
*/
|
43 |
public RasterByteToImageFilter() {
|
44 |
} |
45 |
|
46 |
/* (non-Javadoc)
|
47 |
* @see org.cresques.io.raster.IRasterFilter#pre()
|
48 |
*/
|
49 |
public void pre() { |
50 |
super.pre();
|
51 |
} |
52 |
|
53 |
/* (non-Javadoc)
|
54 |
* @see org.cresques.px.PxRaster.RasterFilter#process(int, int)
|
55 |
*/
|
56 |
public void process(int col, int line) { |
57 |
raster.getElemByte(line, col, px); |
58 |
rgb = (alpha & ((px[3] & 0xff) << 24)) | ((px[0] & 0xff) << 16) | |
59 |
((px[1] & 0xff) << 8) | (px[2] & 0xff); |
60 |
|
61 |
image.setRGB(col, line, rgb); |
62 |
} |
63 |
|
64 |
public void processSuperSampling(int col, int line) { |
65 |
raster.getElemByte(line, col, px); |
66 |
rgb = (alpha & ((px[3] & 0xff) << 24)) | ((px[0] & 0xff) << 16) | |
67 |
((px[1] & 0xff) << 8) | (px[2] & 0xff); |
68 |
|
69 |
for(int j = col; j < raster.getWidth() && j < (col + stepX[contX + 1]); j++) |
70 |
for(int i = line; i < raster.getHeight() && i < (line + stepY[contY + 1]); i++) |
71 |
image.setRGB(j, i, rgb); |
72 |
} |
73 |
|
74 |
/* (non-Javadoc)
|
75 |
* @see org.cresques.io.raster.IRasterFilter#getResult(java.lang.String)
|
76 |
*/
|
77 |
public Object getResult(String name) { |
78 |
return super.getResult(name); |
79 |
} |
80 |
|
81 |
/* (non-Javadoc)
|
82 |
* @see org.cresques.px.PxRaster.RasterFilter#processLines(int)
|
83 |
*/
|
84 |
public void processLine(int y) { |
85 |
for (int x = 0; x < width; x++) { |
86 |
int[][] line = raster.getLineInt(y); |
87 |
rgb = (alpha & ((px[3] & 0xff) << 24)) | |
88 |
((line[x][0] & 0xff) << 16) | ((line[x][1] & 0xff) << 8) | |
89 |
(line[x][2] & 0xff); |
90 |
|
91 |
image.setRGB(x, y, rgb); |
92 |
} |
93 |
} |
94 |
|
95 |
/* (non-Javadoc)
|
96 |
* @see org.cresques.io.raster.IRasterFilter#getInRasterDataType()
|
97 |
*/
|
98 |
public int getInRasterDataType() { |
99 |
return super.getInRasterDataType(); |
100 |
} |
101 |
|
102 |
/* (non-Javadoc)
|
103 |
* @see org.cresques.io.raster.IRasterFilter#getOutRasterDataType()
|
104 |
*/
|
105 |
public int getOutRasterDataType() { |
106 |
return super.getOutRasterDataType(); |
107 |
} |
108 |
|
109 |
/* (non-Javadoc)
|
110 |
* @see org.cresques.io.raster.IRasterFilter#post()
|
111 |
*/
|
112 |
public void post() { |
113 |
super.post();
|
114 |
} |
115 |
} |