[geotk] applet to display raster

Ramzi Oueslati geotoolkit.org at oueslati.org
Wed Jan 12 07:05:49 EST 2011


Hello Martin,

Thanks for your help.

I took a look this morning at the differences between the output of
the appletviewer and the one of the web browser. The missing readers
when the applet runs within the web browser are:

org.geotoolkit.image.io.plugin.GeoTiffImageReader$TIFF
org.geotoolkit.image.io.plugin.WorldFileImageReader$TIFF
com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderSpi
com.sun.media.imageioimpl.plugins.pnm.PNMImageReaderSpi
com.sun.media.imageioimpl.plugins.raw.RawImageReaderSpi
com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi
com.sun.media.imageioimpl.plugins.wbmp.WBMPImageReaderSpi
com.sun.media.imageioimpl.plugins.bmp.BMPImageReaderSpi

I also thought there might be a missing library. I checked and I
confirm that the following libraries are provided to the applet (they
are downloaded with the other jars):

jai_imageio-1.1.jar
geotk-coverageio-3.16.jar

I tried to add the line you suggested yesterday:
IIORegistry.getDefaultInstance().registerServiceProvider(new
GeoTiffImageReader.Spi("TIFF"), ImageReaderSpi.class);
No problem at all when the applet runs from the appletviewer. However,
within the web browser it says:

java.lang.IllegalArgumentException: Image format "TIFF" is unknown.
	at org.geotoolkit.internal.image.io.Formats.getByFormatName(Formats.java:404)
	at org.geotoolkit.internal.image.io.Formats.getReaderByFormatName(Formats.java:342)
	at org.geotoolkit.image.io.plugin.GeoTiffImageReader$Spi.<init>(GeoTiffImageReader.java:98)
	at org.oueslati.applet.RasterApplet.init(RasterApplet.java:61)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown
Source)
	at java.lang.Thread.run(Unknown Source)
Exception: java.lang.IllegalArgumentException: Image format "TIFF" is unknown.

Finally I moved the code which displays what's in the IIORegistry to
the actionPerformed method so that I can check if this issue has to do
with the bug of Sun's implementation. Nothing changed.

I'm now wondering if the jars are really loaded. I saw this kind of
thing in the Java Console:
basic: JNLP2ClassLoader.findClass:
org.geotoolkit.image.io.plugin.GeoTiffImageReader$TIFF: try again ..
basic: JNLP2ClassLoader.findClass:
org.geotoolkit.image.io.plugin.GeoTiffImageReader: try again ..
I haven't got a clue what it means but I will look into it.

Best regards,
Ramzi Oueslati

2011/1/12 Martin Desruisseaux <martin.desruisseaux at geomatys.fr>:
> Hello Ramzi
>
> Le 11/01/11 18:00, Ramzi Oueslati a écrit :
>>
>> I tried the code you suggest and the output is a little different
>> whether it runs from the web browser or the appletviewer. (...)
>>
>>  From web browser
>>
>> (...snip...)
>> org.geotoolkit.image.io.plugin.RawTiffImageReader$Spi at 395aaf
>> (...snip...)
>>
>>  From appletviewer
>>
>> (...snip...)
>> org.geotoolkit.image.io.plugin.GeoTiffImageReader$TIFF at 1a99347
>> (...snip...)
>> com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi at 778255
>> (...snip...)
>> org.geotoolkit.image.io.plugin.RawTiffImageReader$Spi at 1a78071
>
> The GeoTiffImageReader needs an other "plain" TIFF reader for reading the
> pixel values: it basically just wraps a plain TIFF reader and adds metadata
> parsing to it. It appears that all JAI Image I/O plugins, including
> TIFFImageReader, are missing in the web browser (JAI plugins are in the
> com.sun.media.imageioimpl.plugins package). Maybe jai_imageio-1.1.jar were
> not found?
>
> The standard Java library also provides an other TIFF reader,
> com.sun.imageio.plugins.tiff.TIFFImageReader, which could be used instead.
> However for some mysterious Sun's JDK implementation raison, that
> TIFFImageReader appears magically in IIORegistry only after the first AWT
> frame has been shown to the screen. Note also that the JAI TIFFImageReader
> seems better than the JDK one (the TIFF format is the exception; for other
> formats like PNG or JPEG, the JDK implementation seems better than the JAI
> one).
>
> If the TIFF images are uncompressed, a third alternative could be to use the
> Geotk RawTiffImageReader, which is significantly faster than both the JDK
> and JAI implementations. I would need to test however that
> GeoTiffImageReader and RawTiffImageReader works well together.
>
>    Martin
>
>


More information about the Geotoolkit mailing list