<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6000.17080" name=GENERATOR></HEAD>
<BODY style="DISPLAY: block">
<DIV id=idOWAReplyText1641>
<DIV><FONT face="Times New Roman" color=#000000 size=3>Hola, así es como yo había pensado hacerlo:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>===================================</DIV></DIV>
<DIV>import time;<BR>from java.awt.image import *;<BR>from javax.imageio import ImageIO;<BR>from java.io import File;<BR>from gvsiglib import *;</DIV>
<DIV>&nbsp;</DIV>
<DIV>view = gvSIG.getActiveDocument();<BR>mctrl = view.getMapControl();<BR>mcon = mctrl.getMapContext();<BR>vp = mctrl.getViewPort();<BR>lyr=mcon.getLayers().getLayer(0);</DIV>
<DIV><BR>lyr.getSource().start();</DIV>
<DIV><BR>azu0=lyr.getSource().getShape(0);<BR>vp.setExtent(azu0.getBounds2D());</DIV>
<DIV>&nbsp;</DIV>
<DIV>// tamaño de azulejo en la pantalla /(pixels)<BR>w = vp.fromMapDistance(azu0.getBounds2D().getWidth());<BR>h = vp.fromMapDistance(azu0.getBounds2D().getHeight());</DIV>
<DIV>&nbsp;</DIV>
<DIV>// imagen de ese tamaño<BR>bimg = BufferedImage(w,h, BufferedImage.TYPE_INT_RGB);</DIV>
<DIV><BR>// en su objeto graf se puede dibujar<BR>graf = bimg.createGraphics();</DIV>
<DIV>&nbsp;</DIV>
<DIV>// desplazamiento del mapa respecto a azulejo<BR>offsetxmap = azu0.getBounds2D().getMinX()-vp.getAdjustedExtent().getMinX();<BR>offsetymap = vp.getAdjustedExtent().getMaxY()-azu0.getBounds2D().getMaxY();</DIV>
<DIV>&nbsp;</DIV>
<DIV>// desplazamiento del mapa respecto a azulejo<BR>offsetxpix = vp.fromMapDistance(offsetxmap);<BR>offsetypix = vp.fromMapDistance(offsetymap);</DIV>
<DIV>&nbsp;</DIV>
<DIV>// se dibuja el mapa en la imagen creada (como un clip)</DIV>
<DIV>graf.drawImage(mctrl.getImage(), -offsetxpix, -offsetypix, w, h, None);</DIV>
<DIV>// se escribe la imagen en PNG<BR>ImageIO.write(bimg,'png',File('c:/tempo/azulejo.png'))</DIV>
<DIV>===================================</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>pero creo que hay algún error en los cálculos. Tienes que revisarlo, pero creo que de esa manera se puede hacer.</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face="Times New Roman" color=#000000 size=3></FONT>&nbsp;</DIV>
<DIV>Saludos,</DIV></DIV>
<DIV id=idSignature89908>
<DIV><FONT face="Courier New" size=2><FONT face="Times New Roman" size=3>Juan Lucas Domínguez Rubio<BR></FONT>---</FONT></DIV>
<DIV><FONT face="Courier New" size=2><FONT face="Courier New" size=2><FONT face="Courier New" size=2>Prodevelop SL, Valencia (España)</FONT></DIV>
<DIV>
<DIV><FONT face="Courier New" size=2>Tlf.: 96.351.06.12 -- Fax: 96.351.09.68<BR></FONT><A href="http://www.prodevelop.es/"><FONT face="Courier New" size=2>http://www.prodevelop.es</FONT></A><BR><FONT face="Courier New" size=2>---</FONT></DIV></FONT></DIV></FONT></DIV>
<DIV><BR>
<HR>
<FONT face=Tahoma size=2><B>De:</B> gvsig_desarrolladores-bounces@listserv.gva.es en nombre de Steffen Koch<BR><B>Enviado el:</B> mar 21/09/2010 20:39<BR><B>Para:</B> Lista de Desarrolladores de gvSIG<BR><B>Asunto:</B> Re: [Gvsig_desarrolladores] vista - exportar - imagen - jython<BR></FONT><BR></DIV>
<DIV><SPAN style="FONT-SIZE: 9pt"><SPAN style="FONT-FAMILY: verdana,geneva"><SPAN style="BACKGROUND-COLOR: transparent"><SPAN style="COLOR: #000000"><SPAN style="COLOR: #000000">Hola Juan Lucas,<BR><BR>gracias por tu respuesta. Bueno quiero utilizar un fichero de shape (polígono) para averiguar los tamanos de la vista. He empezado a programar el scripting de python con estas lineas:<BR><BR>#importar gvSIG funciones <BR>from gvsiglib import * <BR><BR>#view, mapcontrol, mapcontext <BR>view = gvSIG.getActiveDocument() <BR>mctrl = view.getMapControl() <BR>mcon = mctrl.getMapContext() <BR><BR># la primera capa<BR>lyr= mcon.getLayers().getLayer(0) <BR><BR>#el primer polígono<BR>azulejo1 = lyr.getsource().getShape(0)<BR><BR>#las coordenadas<BR>bazulejo1 = azulejo1.getBounds2D()<BR>xmax = bazulejo1.getMaxX()<BR>xmin = bazulejo1.getMinX()<BR>ymax = bazulejo1.getMaxY()<BR>...<BR><BR>ahora no tengo claro, es que pensaba que puedo cortar&nbsp;un sector (polígono)&nbsp;de la vista, - pero con&nbsp;el método&nbsp;BufferedImage tengo que definir la altura y la anchura de la vista&nbsp;y yo queria solucionar el problema con definir el sector con las coordinadas, porque&nbsp;igual son 5 o 37 polígonos/azulejos. Hay&nbsp;otra possibilidad de cortar azulejos?<BR><BR>Saludos, Stef&nbsp;<BR><BR><BR><BR><BR><BR></SPAN></SPAN></SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt"><SPAN style="FONT-FAMILY: verdana,geneva"><SPAN style="BACKGROUND-COLOR: transparent"><SPAN style="COLOR: #000000"><SPAN style="COLOR: #000000"><BR></SPAN></SPAN></SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt"><SPAN style="FONT-FAMILY: verdana,geneva"><SPAN style="BACKGROUND-COLOR: transparent"><SPAN style="COLOR: #000000"><SPAN style="COLOR: #000000">
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: blue 2px solid; PADDING-TOP: 5px">
<HR>
<B>Von:</B> "Juan Lucas Dominguez Rubio" &lt;jldominguez@prodevelop.es&gt;<BR><B>Gesendet:</B> 13.09.2010 13:27:53<BR><B>An:</B> "Lista de Desarrolladores de gvSIG" &lt;gvsig_desarrolladores@listserv.gva.es&gt;, gvsig_desarrolladores@listserv.gva.es<BR><B>Betreff:</B> Re: [Gvsig_desarrolladores] vista - exportar - imagen - jython<BR><BR>
<DIV>
<DIV id=idOWAReplyText22032>
<DIV><SPAN style="FONT-SIZE: small; COLOR: #000000; FONT-FAMILY: Times New Roman">Hola,</SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN style="FONT-SIZE: small; COLOR: #000000; FONT-FAMILY: Times New Roman">¿los bordes de esos&nbsp;cuadrículas (azulejos) cómo se definen?</SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: small; COLOR: #000000; FONT-FAMILY: Times New Roman">¿valdría con que fueran siempre los cuatro cuartos idénticos de la vista actual?</SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV>Creo que yo intentaría esto con jython:</DIV>
<DIV>&nbsp;</DIV>
<DIV>- averiguar el tamaño de la vista en pixels</DIV>
<DIV>- dividir por dos la altura y anchura e instanciar 4 BufferedImage de ese tamaño</DIV>
<DIV>- para cada BufferedImage, usa su Graphics y pinta sobre él la parte del mapa que te interesa (mediante offsets)</DIV>
<DIV>- finalmente, cada bufferedImage puede exportarse a PNG con ImageIO</DIV>
<DIV>&nbsp;</DIV>
<DIV>En algún lugar de MapContext o MapControl habrá una copia del mapa actual (también un BufferedImage, probablemente)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Sería más o menos así</DIV>
<DIV>...</DIV>
<DIV>
<DIV>BufferedImage azulejo2 = new BuferredImage(w/2, h/2);</DIV>
<DIV>Graphics azugra2 =&nbsp;azulejo2.createGraphics();</DIV>
<DIV>azugra2.paintImage(mapa_actual, -w/2, 0);</DIV>
<DIV>ImageIO.export(azulejo2, "png", "c:\\imagenes\\img2.png")</DIV>
<DIV>(o algo así)</DIV>...</DIV>
<DIV>&nbsp;</DIV>
<DIV>Al poner -w/2, hacemos un 'clip' de la zona de interés.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Saludos,</DIV>
<DIV><SPAN style="FONT-SIZE: small; COLOR: #000000; FONT-FAMILY: Times New Roman"></SPAN>&nbsp;</DIV></DIV>
<DIV id=idSignature97159>
<DIV><SPAN style="FONT-SIZE: x-small; FONT-FAMILY: Courier New"><SPAN style="FONT-SIZE: small; FONT-FAMILY: Times New Roman">Juan Lucas Domínguez Rubio<BR></SPAN>---</SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: x-small; FONT-FAMILY: Courier New"><SPAN style="FONT-SIZE: x-small; FONT-FAMILY: Courier New"><SPAN style="FONT-SIZE: x-small; FONT-FAMILY: Courier New">Prodevelop SL, Valencia (España)</SPAN></SPAN></SPAN></DIV>
<DIV>
<DIV><SPAN style="FONT-SIZE: x-small; FONT-FAMILY: Courier New">Tlf.: 96.351.06.12 -- Fax: 96.351.09.68<BR></SPAN><A href="http://www.prodevelop.es/"><SPAN style="FONT-SIZE: x-small; FONT-FAMILY: Courier New">http://www.prodevelop.es</SPAN></A><BR><SPAN style="FONT-SIZE: x-small; FONT-FAMILY: Courier New">---</SPAN></DIV></DIV></DIV>
<DIV><BR>
<HR>
<SPAN style="FONT-SIZE: x-small; FONT-FAMILY: Tahoma"><B>De:</B> gvsig_desarrolladores-bounces@listserv.gva.es en nombre de Steffen Koch<BR><B>Enviado el:</B> jue 02/09/2010 13:16<BR><B>Para:</B> gvsig_desarrolladores@listserv.gva.es<BR><B>Asunto:</B> [Gvsig_desarrolladores] vista - exportar - imagen - jython<BR></SPAN></DIV>
<DIV>
<P><SPAN style="FONT-SIZE: x-small">hola,<BR><BR>estoy buscando un camino para exportar automaticamente la vista a imagenes, igual no funciona con gvsig, no se - es que tengo en mi ejemplo 4 rectángulos/azulejos que quiero exportar cada uno como imagen, pero automaticamente con la ayuda de jython. Tenéis una idea como podría funcionar. Gracias por vuestra ayuda.<BR><BR>Saludos, Stef<BR>___________________________________________________________<BR>Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief!&nbsp;<BR>Jetzt De-Mail-Adresse reservieren: <A href="https://produkte.web.de/go/demail02">https://produkte.web.de/go/demail02</A><BR></SPAN></P></DIV></DIV></BLOCKQUOTE></SPAN></SPAN></SPAN></SPAN></SPAN>&nbsp;&nbsp;<BR><BR>
<TABLE cellspacing=0 cellpadding=0 border=0>
<TBODY>
<TR>
<TD bgcolor=#000000><IMG height=1 width=1 border=0></TD></TR>
<TR>
<TD style="FONT-SIZE: 12px; LINE-HEIGHT: 17px; FONT-FAMILY: verdana">GRATIS: Spider-Man 1-3 sowie 300 weitere Videos!&nbsp;&nbsp;&nbsp;<BR>Jetzt kostenlose Movie-FLAT freischalten! <A href="http://movieflat.web.de/"><B>http://movieflat.web.de</B></A></TD></TR></TBODY></TABLE></DIV></BODY></HTML>