Ciao Martin,
I am happy with this change which would conserve the expected
behaviour, at least for the moment.

As per others successive emails, +1 on committing everything.


Ciao,
Simone.

On Jan 11, 2008 4:22 PM, Martin Desruisseaux
<[EMAIL PROTECTED]> wrote:
> Simone Giannecchini a écrit :
> > I guess that since ImageWorker does not really focus on writing images
> > out ,using a fixed writer that we know that works is not that bad.
> > Anyway if this causes you some troubles I guess we can remove this
> > ilimitation and state in the javadoc that GIF writing has been tested
> > only using the Imageio writer. The JIRA would help keep track of some
> > investigation/work I will have to do on this.
>
>
> Yes I understood that and my plan was to stick to exactly the same GIF writter
> than today, but through IIORegistry mechanism (basically looking at the class
> name) rather than hard-coded dependency.
>
> Current code is:
>
>   final ImageOutputStream ios = ImageIO.createImageOutputStream(destination);
>   final ImageWriter gifWriter = new GIFImageWriter(gifSPI);
>
> The last line could probably be safely replaced by:
>
>   final ImageWriter gifWriter = gifSPI.createWriterInstance();
>
> The first line could be replaced by:
>
>   final IIORegistry registry = IIORegistry.getDefaultInstance();
>   Iterator<ImageWriterSpi> it =
> registry.getServiceProviders(ImageWriterSpi.class, true);
>   ImageWriterSpi spi = null;
>   while (it.hasNext()) {
>       final ImageWriterSpi candidate = it.next();
>       if (containsFormatName(candidate.getFormatNames(), "gif")) {
>           if (spi == null) {
>               spi = candidate;
>           } else {
>               final String type = candidate.getClass().getName();
>               if
> (type.equals("com.sun.media.imageioimpl.plugins.gif.GIFImageWriterSpi")) {
>                   spi = candidate;
>                   break;
>               }
>           }
>       }
>   }
>   if (spi == null) {
>       throw new IIOException(Errors.format(ErrorKeys.NO_IMAGE_WRITER));
>   }
>
>
> This is complicated stuff for replacing a single line, I admit. But it avoid
> completly the direct dependency. The ImageIO GIF encoder is preferred if found
> because of the type.equals("...") check, otherwise the first suitable encoder 
> is
> used.
>
>         Martin
>



-- 
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041  Camaiore (LU)
Italy

phone: +39 0584983027
fax:      +39 0584983027
mob:    +39 333 8128928


http://www.geo-solutions.it

-------------------------------------------------------

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to