Here you can find the source of guessCompressionRatio(final ImageReaderWriterSpi spi)
Parameter | Description |
---|---|
spi | The image reader or writer provider. |
public static int guessCompressionRatio(final ImageReaderWriterSpi spi)
//package com.java2s; /*/*from ww w . ja v a 2 s . c om*/ * Geotoolkit.org - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2009-2012, Open Source Geospatial Foundation (OSGeo) * (C) 2009-2012, Geomatys * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import javax.imageio.spi.ImageReaderWriterSpi; public class Main { /** * Guesses the compression ratio for the given image format. This is very approximative * and used only in order to have some order of magnitude. * * @param spi The image reader or writer provider. * @return The inverse of a guess of compression ratio (1 is uncompressed), or 0 if unknown. */ public static int guessCompressionRatio(final ImageReaderWriterSpi spi) { if (spi != null) { for (final String format : spi.getFormatNames()) { if (format.equalsIgnoreCase("png")) { return 4; } if (format.equalsIgnoreCase("jpeg")) { return 8; } if (format.equalsIgnoreCase("tiff")) { // TIFF are uncompressed unless explicitly specified. return 1; } if (format.equalsIgnoreCase("bmp") || format.equalsIgnoreCase("raw")) { return 1; } } } return 0; } }