Take a look at 
http://72.5.124.55/products/java-media/jai/forDevelopers/jai-apidocs/javax/m 
edia/jai/remote/SerializableRenderedImage.html 

from the jai (Java advanced imaging ) 


Martin Tomko writes: 

> Dear all,
> I need to pass around the results of my coverage processing (a 
> Coverage2D, or a geotiff, both are acceptable)  through an XML (as a 
> xsd:base64Binary). The coverages will be VERY small. 
> 
> In order to do that, I need to serialize the object (the coverage). I 
> have found some code doing something like that:
>     public static byte[] toBytes(Object object){
>         java.io.ByteArrayOutputStream baos = new 
> java.io.ByteArrayOutputStream();
>         try{
>             java.io.ObjectOutputStream oos = new 
> java.io.ObjectOutputStream(baos);
>             oos.writeObject(object);
>         }catch(java.io.IOException ioe){
>         }
>         return baos.toByteArray();
>     } 
> 
> But it does not seem to work with coverages:
> Exception in thread "main" java.lang.IllegalArgumentException: No 
> Serializers available for the ColorModel.
>     at 
> javax.media.jai.remote.SerializableRenderedImage.<init>(SerializableRenderedImage.java:507)
>     at 
> javax.media.jai.remote.SerializableRenderedImage.<init>(SerializableRenderedImage.java:390)
>     at 
> org.geotools.coverage.grid.GridCoverage2D.writeObject(GridCoverage2D.java:1034)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at 
> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
>     at 
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
>     at 
> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>     at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>     at ch.uzh.geo.tomko.service.VService.toBytes(VService.java:492) 
> 
> It seems that specific serializers are invoked for the rendered image. 
> Can anyone please point me to a solution? Note that my coverage 
> currently does not have a color model assigned (it has only 6 values - 
> In general I need it for DEMs etc...). I tried to set the coverage 
> ViewType to Geophysics or Rendered, but that did not help.
> I need the actual values of the cells to be preserved in the output. 
> 
> Thank for any help,
> Martin 
> 
> 
> ------------------------------------------------------------------------------
> Stay on top of everything new and different, both inside and 
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today. 
> Use priority code J9JMT32. http://p.sf.net/sfu/p
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
 


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to