package pl.wroc.pwr.image.io; import net.sourceforge.jiu.codecs.BMPCodec; import net.sourceforge.jiu.codecs.GIFCodec; import net.sourceforge.jiu.codecs.IFFCodec; import net.sourceforge.jiu.codecs.ImageCodec; import net.sourceforge.jiu.codecs.PNGCodec; import net.sourceforge.jiu.codecs.PNMCodec; import net.sourceforge.jiu.codecs.tiff.TIFFCodec; public class ImageCodecPicker { private static String BMP_FORMAT = ".bmp"; //$NON-NLS-1$ private static String GIF_FORMAT = ".gif"; //$NON-NLS-1$ private static String PNG_FORMAT = ".png"; //$NON-NLS-1$ private static String IFF_FORMAT = ".iff"; //$NON-NLS-1$ private static String PNM_FORMAT = ".pnm"; //$NON-NLS-1$ private static String TIF_FORMAT = ".tif"; //$NON-NLS-1$ private static String TIFF_FORMAT = ".tiff"; //$NON-NLS-1$ public static ImageCodec getCodec( String fileName ) { String lowercaseFileName = fileName.toLowerCase( ); if ( lowercaseFileName.contains( BMP_FORMAT ) ) { return new BMPCodec( ); } if ( lowercaseFileName.contains( GIF_FORMAT ) ) { return new GIFCodec( ); } if ( lowercaseFileName.contains( PNG_FORMAT ) ) { return new PNGCodec( ); } if ( lowercaseFileName.contains( IFF_FORMAT ) ) { return new IFFCodec( ); } if ( lowercaseFileName.contains( PNM_FORMAT ) ) { return new PNMCodec( ); } if ( lowercaseFileName.contains( TIF_FORMAT ) ) { return new TIFFCodec( ); } if ( lowercaseFileName.contains( TIFF_FORMAT ) ) { return new TIFFCodec( ); } return null; } }