Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* $RCSfile: BMPImageReaderSpi.java,v $
*
*
* Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any
* kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
* EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
* NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
* USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
* ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
* CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
* REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for
* use in the design, construction, operation or maintenance of any
* nuclear facility.
*
* $Revision: 1.3 $
* $Date: 2006/03/31 19:43:38 $
* $State: Exp $
*/
package com.github.jaiimageio.impl.plugins.bmp;
import java.io.IOException;
import java.util.Locale;
import javax.imageio.IIOException;
import javax.imageio.ImageReader;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.spi.ServiceRegistry;
import javax.imageio.stream.ImageInputStream;
import com.github.jaiimageio.impl.common.ImageUtil;
import com.github.jaiimageio.impl.common.PackageUtil;
public class BMPImageReaderSpi extends ImageReaderSpi {
private static String [] writerSpiNames =
{"com.github.jaiimageio.impl.plugins.bmp.BMPImageWriterSpi"};
private static String[] formatNames = {"bmp", "BMP"};
private static String[] extensions = {"bmp"};
private static String[] mimeTypes = {
"image/bmp", "image/x-bmp", "image/x-windows-bmp"
};
private boolean registered = false;
public BMPImageReaderSpi() {
super(PackageUtil.getVendor(),
PackageUtil.getVersion(),
formatNames,
extensions,
mimeTypes,
"com.github.jaiimageio.impl.plugins.bmp.BMPImageReader",
STANDARD_INPUT_TYPE,
writerSpiNames,
false,
null, null, null, null,
true,
BMPMetadata.nativeMetadataFormatName,
"com.github.jaiimageio.impl.plugins.bmp.BMPMetadataFormat",
null, null);
}
public void onRegistration(ServiceRegistry registry,
Class category) {
if (registered) {
return;
}
registered = true;
// By JDK 1.7, the BMPImageReader will have been in JDK core for
// atleast two FCS releases, so we can set JIIO's to lower priority
// With JDK 1.8, we can entirely de-register the JIIO one
ImageUtil.processOnRegistration(registry, category, "BMP", this,
8, 7); // JDK version 1.8, 1.7
}
public String getDescription(Locale locale) {
String desc = PackageUtil.getSpecificationTitle() +
" BMP Image Reader";
return desc;
}
public boolean canDecodeInput(Object source) throws IOException {
if (!(source instanceof ImageInputStream)) {
return false;
}
ImageInputStream stream = (ImageInputStream)source;
byte[] b = new byte[2];
stream.mark();
stream.readFully(b);
stream.reset();
return (b[0] == 0x42) && (b[1] == 0x4d);
}
public ImageReader createReaderInstance(Object extension)
throws IIOException {
return new BMPImageReader(this);
}
}