/********************************************************************** * $Id$ * * Name: Example.java * Project: * Purpose: * Author: Nacho Brodin, brodin_ign@gva.es * **********************************************************************/ /* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana * * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. * * For more information, contact: * * Generalitat Valenciana * Conselleria d'Infraestructures i Transport * Av. Blasco Ibáñez, 50 * 46010 VALENCIA * SPAIN * * +34 963862235 * gvsig@gva.es * www.gvsig.gva.es * * or * * IVER T.I. S.A * Salamanca 50 * 46005 Valencia * Spain * * +34 963163400 * dac@iver.es */ import es.gva.cit.jmrsid.*; import java.io.*; /** * Genera una imagen .raw a partir de un mrsid. Hay que definir el tamaño de la ventana que * queremos convertir pasando el ancho y el alto. Además mostrará alguna información sobre la * imagen. * * @author Nacho Brodin .
Equipo de desarrollo gvSIG.
http://www.gvsig.gva.es * @version 0.0 * @link http://www.gvsig.gva.es */ public class Example { public static void main(String[] args){ LTIImageReader img; LTIMetadataDatabase metadata; LTIPixel pixel; int eColorSpace, nBands, eSampleType; int tamx=Integer.parseInt(args[1]); int tamy=Integer.parseInt(args[2]); int siz = tamx * tamy * 1; try{ img = new MrSIDImageReader(args[0]); img.initialize(); int overviews=((MrSIDImageReader)img).getNumLevels()-1; System.out.println("Overviews="+overviews); System.out.println("Width="+img.getWidth()); System.out.println("Height="+img.getHeight()); System.out.println("Stripsheigth="+img.getStripHeight()); nBands=img.getNumBands(); System.out.println("NumBands="+nBands); eColorSpace=img.getColorSpace(); System.out.println("ColorSpace="+eColorSpace); eSampleType=img.getDataType(); System.out.println("DataType="+eSampleType); pixel=new LTIPixel(eColorSpace, nBands, eSampleType); int[] dimsAtMag=img.getDimsAtMag(0.5); System.out.println("Dims At Mag 0,5="+dimsAtMag[0]+" "+dimsAtMag[1]); System.out.println("************************************"); //Acceso a metadatos metadata=img.getMetadata(); System.out.println("Metadatos="+metadata.getIndexCount()); for (int i=0; i"+s[j]); }else if(rec.isArray()){ String[] s = rec.getArrayData(); for(int j=0;j"+s[j]); } else System.out.println(""); } //Fin metadatos System.out.println("************************************"); //Acceso a la información de georeferenciación LTIGeoCoord geoc = img.getGeoCoord(); System.out.println("X="+geoc.getX()); System.out.println("Y="+geoc.getY()); System.out.println("XRes="+geoc.getXRes()); System.out.println("YRes="+geoc.getYRes()); System.out.println("XRot="+geoc.getXRot()); System.out.println("YRot="+geoc.getYRot()); //Fin de acceso a la información de georeferenciación System.out.println("************************************"); LTIScene scene=new LTIScene(0,0,tamx,tamy,1.0); LTISceneBuffer buffer=new LTISceneBuffer(pixel,tamx,tamy,true); ((LTIImageStage)img).read(scene,buffer); FileOutputStream s=null; try{ File mifichero=new File("exit.raw"); s = new FileOutputStream(mifichero); }catch(Exception e){} try{ for(int j=0;j