Revision 22816

View differences:

trunk/libraries/libRaster/src-test/TestUIConvolution.java
1

  
2

  
3
import javax.swing.JFrame;
4

  
5
import org.gvsig.raster.grid.filter.convolution.ConvolutionUI;
6

  
7
/**
8
 * Clase para poder ver la ventana de las Tablas de color
9
 *
10
 * @version 17/04/2007
11
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
12
 */
13
public class TestUIConvolution {
14
	private JFrame 			frame = new JFrame();
15

  
16
	public TestUIConvolution() {
17
		super();
18
		initialize();
19
	}
20

  
21
	public static void main(String[] args){
22
		new TestUIConvolution();
23
	}
24

  
25
	private void initialize() {
26
		ConvolutionUI ui = new ConvolutionUI(null);
27
		frame.setContentPane(ui);
28
		frame.setSize(new java.awt.Dimension(220, 190));
29
		frame.setResizable(true);
30
		frame.setTitle("Convolution");
31
		frame.setVisible(true);
32
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
33
	}
34
}
trunk/libraries/libRaster/src-test/org/gvsig/raster/potrace/TestRasterPotrace.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.raster.potrace;
20

  
21
import org.gvsig.jpotrace.Potrace;
22
import org.gvsig.jpotrace.PotraceException;
23
import org.gvsig.raster.buffer.BufferFactory;
24
import org.gvsig.raster.buffer.RasterBuffer;
25
import org.gvsig.raster.dataset.NotSupportedExtensionException;
26
import org.gvsig.raster.dataset.RasterDataset;
27
import org.gvsig.raster.dataset.io.RasterDriverException;
28
/**
29
 * 
30
 * @version 05/08/2008
31
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
32
 */
33
public class TestRasterPotrace {
34
	private String baseDir = "./test-images/";
35
//	private String path1 = baseDir + "wheel.bmp";
36
	private String path1 = baseDir + "letters.bmp";
37

  
38
	private RasterDataset f1 = null;
39
	
40
	public TestRasterPotrace() {
41
		try {
42
			f1 = RasterDataset.open(null, path1);
43
			BufferFactory ds = new BufferFactory(f1);
44
			ds.setAllDrawableBands();
45
			ds.setAreaOfInterest();
46
			RasterBuffer buf = (RasterBuffer) ds.getRasterBuf();
47

  
48
			int dy = (buf.getWidth() + 64 - 1) / 64;
49

  
50
			long[] bufferBits = new long[buf.getHeight() * dy];
51

  
52
			for (int i = 0; i < bufferBits.length; i++)
53
				bufferBits[i] = 0;
54
			
55
			int bit = 0;
56
			int pos = 0;
57
//			for (int j = 0; j < buf.getWidth(); j++) {
58
			for (int i = 0; i < buf.getHeight(); i++) {
59
				pos = (buf.getHeight() - i - 1) * dy;
60
				bit = 0;
61
//			for (int i = 0; i < buf.getHeight(); i++) {
62
				for (int j = 0; j < buf.getWidth(); j++) {
63
					byte data = buf.getElemByte(i, j, 0);
64

  
65
					if (data == 0) {
66
						bufferBits[pos] += (1 << (63-bit));
67
//						if (bit < 32)
68
//							bufferBits[pos] += (1 << (63-bit+32));
69
//						else
70
//							bufferBits[pos] += (1 << j);
71
					}
72
					
73
					bit++;
74
					if (bit >= 64) {
75
						bit = 0;
76
						pos++;
77
					}
78
				}
79
			}
80

  
81
			// binario
82
			
83
			Potrace.vectorizeBufferRaster(bufferBits, buf.getWidth(), buf.getHeight(), "C:\\TEMP\\nacho.eps");
84
		} catch (NotSupportedExtensionException e) {
85
			e.printStackTrace();
86
		} catch (RasterDriverException e) {
87
			e.printStackTrace();
88
		} catch (InterruptedException e) {
89
			e.printStackTrace();
90
		} catch (PotraceException e) {
91
			e.printStackTrace();
92
		}
93
	}
94

  
95
	public static void main(String[] args){
96
		new TestRasterPotrace();
97
	}
98
}
trunk/libraries/libRaster/src-test/org/gvsig/raster/grid/filter/TestUIConvolution.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.raster.grid.filter;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.grid.filter.convolution.ConvolutionUI;
24
/**
25
 * Clase para poder ver la ventana de las Tablas de color
26
 *
27
 * @version 28/09/2007
28
 * @author Nacho Brodin nachobrodin@gmail.com
29
 */
30
public class TestUIConvolution {
31
	private JFrame 			frame = new JFrame();
32

  
33
	public TestUIConvolution() {
34
		super();
35
		initialize();
36
	}
37

  
38
	public static void main(String[] args){
39
		new TestUIConvolution();
40
	}
41

  
42
	private void initialize() {
43
		ConvolutionUI ui = new ConvolutionUI(null);
44
		frame.setContentPane(ui);
45
		frame.setSize(new java.awt.Dimension(220, 190));
46
		frame.setResizable(true);
47
		frame.setTitle("Convolution");
48
		frame.setVisible(true);
49
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
50
	}
51
}

Also available in: Unified diff