<HTML dir=ltr><HEAD><TITLE>Re: [Gvsig_english] Code Question - raster layers</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6000.16890" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText15843 dir=ltr>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>Hello, Aldo.</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>Yes, we know that the VM sometimes (I think J9 doesn't) uses a new thread when dealing with images (reading or resampling), that's why we wrote this method:</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>public static Image getScaled(Image img, int newwidth, int newheight);</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>in the ResourceReader class, but I think we forgot to use it in the draw method of the WKFRasterDriver class :-/</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>So I think you have these three options:</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>- Use the J9 version (as I said, I think J9 loads/resamples images in the main thread)</FONT></DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>- Edit the code, use that method and compile</FONT></DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>- Convert your JPG/PNG/GIF images to ECW with Gdal ( <A href="http://fwtools.maptools.org">http://fwtools.maptools.org</A> )</FONT></DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>Even if you use J9 or fix the bug yourself, I recommend using ECW because the other formats are a great bother. After loading one of those images, the application becomes more unstable.</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>Thanks for reporting this problem.</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>As for the rotation, we simply ignore it. The second and third parameters of the world file (*.WLD) are not used at all, sorry. Again, with Gdal you can convert a rotated image (PNG/JPG/GIF + WLD file with non-zero values in second and third line) into a ECW file which will obviously have black triangles by the margins. In this case, you need two steps:</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>gdalwarp image.jpg image.tif</FONT></DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>gdal_translate -of ecw image.tif image.ecw</FONT></DIV>
<DIV dir=ltr>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3>Regards,</FONT></DIV>
<DIV dir=ltr><FONT face="Times New Roman" color=#000000 size=3></FONT>&nbsp;</DIV></DIV>
<DIV id=idSignature58395 dir=ltr>
<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>Prodevelop SL, Valencia (España)</FONT></DIV>
<DIV><FONT face="Courier New" size=2>0° 22' 49.62" W, 39° 28' 25.45" N<BR>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></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>De:</B> gvsig_internacional-bounces@listserv.gva.es en nombre de Aldo Stracquadanio<BR><B>Enviado el:</B> mié 16/09/2009 13:00<BR><B>Para:</B> Users and Developers mailing list<BR><B>Asunto:</B> Re: [Gvsig_english] Code Question - raster layers<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Hi Juan,<BR><BR>I know about the limitation of 400k pixels, I will send you the<BR>exported project I'm working on as soon as I will be in my office. The<BR>problem with resampling of the image is that a<BR>clipping-translating-composition can't resolve the rotation part of a<BR>generic affine transform (and I think in my image it's needed a little<BR>rotation too).<BR><BR>Moreover I see that you use the getScaledInstance method to get a<BR>scaled instance of the image and immediatly after this you check for<BR>width. This often gives me -1 (causing an exception) because this<BR>method (like the most of the graphics methods of CDC) can exibit an<BR>asynchronus behavior; have you ever had such problems?<BR><BR>Regards,<BR>Aldo Stracquadanio.<BR><BR>2009/9/15 Juan Lucas Dominguez Rubio &lt;jldominguez@prodevelop.es&gt;:<BR>&gt; Hello, Aldo.<BR>&gt;<BR>&gt; As you say, the Graphics2D class in CDC knows nothing about affine<BR>&gt; transforms, so you always have to provide 'final' coordinates, that is,<BR>&gt; screen coordinates.<BR>&gt;<BR>&gt; The Image class has a resample method and of course there are ways to clip<BR>&gt; an image, so all you have to do is clipping and resizing the image until you<BR>&gt; have the final image, and then paste it in the correct coordinates on the<BR>&gt; screen, that's what the WKRasterDriver does.<BR>&gt;<BR>&gt; These images (we're talking about JPG, PNG and GIF images; the ECW driver is<BR>&gt; totally different) are very memory-consuming and can only be loaded if the<BR>&gt; have less than 400,000 pixels. If we tried to open larger images, the<BR>&gt; virtual machine itself would be at risk.<BR>&gt;<BR>&gt; We tried to do the clipping and resampling in such a way that we never need<BR>&gt; to instantiate a large image, but maybe this is not always possible.<BR>&gt;<BR>&gt; Can you send us the log files under \gvSIGMobile\log\ or even the image<BR>&gt; itself?<BR>&gt;<BR>&gt;<BR>&gt; Regards,<BR>&gt; Juan Lucas Domínguez Rubio<BR>&gt; ---<BR>&gt; Prodevelop SL, Valencia (España)<BR>&gt; 0° 22' 49.62" W, 39° 28' 25.45" N<BR>&gt; Tlf.: 96.351.06.12 -- Fax: 96.351.09.68<BR>&gt; <A href="http://www.prodevelop.es/">http://www.prodevelop.es</A><BR>&gt; ---<BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt; -----Mensaje original-----<BR>&gt; De: gvsig_internacional-bounces@listserv.gva.es en nombre de Aldo<BR>&gt; Stracquadanio<BR>&gt; Enviado el: mar 15/09/2009 18:32<BR>&gt; Para: gvsig_internacional@listserv.gva.es<BR>&gt; Asunto: [Gvsig_english] Code Question - raster layers<BR>&gt;<BR>&gt; Hi everybody,<BR>&gt;<BR>&gt; I'm reading the phoneME Mobile source code, but I can't understand<BR>&gt; something about the WKFRasterDriver: if there is no support for<BR>&gt; AffineTransform in CDC, how do you obtain a "shear" effect using only<BR>&gt; scaling-translation operations? I can't figure it out and, as well,<BR>&gt; the raster layer visualization is not working at all on my<BR>&gt; installation: in my opinion there is some problem with the asynchronus<BR>&gt; behaviour of the Image.getScaledInstance method since I get a "Cannot<BR>&gt; resample (down)".<BR>&gt;<BR>&gt; Can someone help me understanding?<BR>&gt; Thank's all, Aldo Stracquadanio.<BR>&gt; _______________________________________________<BR>&gt; Gvsig_internacional mailing list<BR>&gt; Gvsig_internacional@listserv.gva.es<BR>&gt; <A href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</A><BR>&gt;<BR>&gt;<BR>&gt; _______________________________________________<BR>&gt; Gvsig_internacional mailing list<BR>&gt; Gvsig_internacional@listserv.gva.es<BR>&gt; <A href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</A><BR>&gt;<BR>&gt;<BR>_______________________________________________<BR>Gvsig_internacional mailing list<BR>Gvsig_internacional@listserv.gva.es<BR><A href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</A><BR></FONT></P></DIV></BODY></HTML>